Running a multi-service app
In most cases, applications do not consist of only one monolithic block, but rather of several application services that work together. When using Docker containers, each application service runs in its own container. When we want to run such a multi-service application, we can, of course, start all the participating containers with the well-known docker container run
command, and we have done this in previous chapters. But this is inefficient at best. With the Docker Compose tool, we are given a way to define the application in a declarative way in a file that uses the YAML format.
Let’s create and analyze a simple docker-compose.yml
file:
- Inside the chapter’s folder (
ch11
), create a subfolder calledstep1
and navigate to it:$ mkdir step1 && cd step1
- Inside this folder, add a file called
docker-compose.yml
and add the following snippet to it:
Figure 11.1 – Simple Docker Compose file...