- In this approach, each module (web, server, database) resides in different containers.
- We have to write different docker files for each
- There will be different images for each also.
- Only the thing is docker-compose is another top-level file that binds and connects all those images in one project.
- It is the standard approach that helps in the micro-system approach.
- Here initially we have tried it for our project and then switched to another approach.
How docker-compose works?
- Use YAML files to configure application services (docker-compose.yaml)
- Can start all the services with a single command ( docker-compose up )
- Can stop all the service with a single command ( docker-compose down )
- Able to scale up the specific services when required.
- Works in all environments: production, staging, development, testing, as well as CI workflows
Docker-compose file looks like
- db — it is a database used by the project
- server — It is a server-side module
- web — it is web side module.
- Build, image, port, environment are configurations which helps in building image and linking images with each other.
For more details about the docker-compose approach and implementation go through the following reference links.