The docker-compose Tool
Let's begin the lesson by looking at what a multi-container setup is, why it is important, and how Docker, with the tool docker-compose, works like a charm in such scenarios.
We have recently been introduced to how applications work, with their separate elements: frontend, backend, and database.
To run such a multi-tier application using Docker, one would need to run the following commands to spin up the containers in different terminal sessions:
- docker run <front-end>
- docker run <back-end>
- docker run <database>Note
You can run docker run with (-d) as detached to prevent us from running the three commands in separate sessions, for example: docker run <front-end> -d
That said, it even becomes particularly tasking linking different containers (networking).
docker-compose comes in to save the day. We can define and run multi-containers from one file - docker-compose.yml. In the following topics, we'll discuss this further. First,...