Docker Compose I
- Docker Compose is a tool for running multi-container applications. All containers work together. Using the YAML file you can configure your application’s services. With a single command, you can start and stop your entire applications and services.
- Install Docker Compose on macOS, Windows, and 64-bit Linux. Refer to https://docs.docker.com/compose/install/ steps for installations.
- Basic three steps to start the application using docker-compose:
- Create dockerfiles with your app's environment.
- Add configuration of your application’s services in docker-compose.yml, so they can be run together in an isolated environment. You can use either a .yml or .yaml extension for this file. They both work.
- Run docker compose up or docker-compose up and runs your entire app.
- Benefits of Docker Compose:
- You can deploy everything on a single host.
- Easy configuration due to YAML scripts.
- All the containers are isolated from each other.
- Basic Commands in Docker Compose:
- docker-compose up: Create and start containers
- docker-compose start/stop: Start/Stop services
- docker-compose build: Build or rebuild services
- docker-compose bundle: Generate a Docker bundle from the Compose file
- docker-compose config: Validate and view the Compose file
- docker-compose scale: Set number of containers for a service
- docker-compose down: Stop and remove containers, networks, images, and volumes
For more CLI options check https://docs.docker.com/compose/reference/.
Next: Stay tuned for details about Docker-compose files and configurations, in the upcoming blog will be setting up a web service by using docker-compose.yaml.
PS: Please don't copy-paste this article. If you find it useful please feel free to share it, and yes don't forget to give credits.