Utilizing Multi-Container Functionality with IBM Cloud Developer Tools CLI
The latest update to the IBM Cloud Developer Tools CLI, version 1.1.0, provides support for applications that use multiple containers which are configured using Docker Compose yaml files. These files contain necessary information about the containers you wish to run. With Docker installed, you already have the requisite dependency to run multiple containers locally.
Why Multiple Containers?
If you’re wondering why you’d want to use an app that needs multiple containers locally, let’s first think about what makes up a cloud native application, and how you go about building cloud native applications. Let’s consider a basic microservice for reading and writing data from a database. You might have two parts of this service – one being the application (Node, Java, Swift, Python, etc…) and a database… perhaps even a caching server or some other components, but let’s keep it simple for now.
If you’re using a cloud-hosted database, like IBM Cloud’s MongoDB or Cloudant databases, then you might initially think that you only need one container: your application server, because you are hitting a database in the cloud. Now ask yourself, “Do I want to be able to work on my application while disconnected from the cloud?” or “Is there is a free tier for my production system’s cloud database?” Both wanting to be able to work offline with a local database, and wanting to use local OSS instances of the database are cases where you might want a project that uses multiple containers. With multiple containers, you can have your entire environment contained locally, which you can manage and coordinate using Docker Compose files.
Running with Multiple Containers
To run with multiple containers, you must provide the path to a Docker Compose file in the
cli-config.yml for the
or provide the path via command line as such:
The Compose file should be a valid .YML or .YAML file and specify your application’s services. By providing the Compose file, the Developer Tools CLI recognizes that you want to run with multiple containers. There are no additional options that you need to pass to specify running multiple containers. The
stop commands use the
You may also wish to debug or test with multiple containers. If so, you would, similarly, provide the path to your Compose file in the
cli-config.yml for the
dockerfile-tools entry or via the command line. This file would be used for the
Additionally, you may find it helpful to have several Compose files with various properties for running and testing different scenarios. In that case, you can provide multiple Compose files for both
dockerfile-tools entries. In the
cli-config.yml, the files should be separated by commas.
If you provide the paths via command line, you must surround a comma-delimited list of Compose files with double quotes.
Each successive Compose file that is provided will have higher priority in the case of duplicated entries. If you create your own Compose file, be sure to add the
tty: true option to your service. This will ensure that the container remains running and does not exit upon running the
bx dev run command.