Docker Compose
Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application's services. Then, with a single command, you create and start all the services from your configuration.
Docker Compose Use Case
When you're developing software, the ability to run an application in an isolated environment and interact with it is crucial.
The Compose file provides a way to document and configure all of the application's service dependencies (databases,queues, caches, web service APIs,etc)
Docker Compose Quickstart
There are 3 step process:
1- Define your app's environment with a Dockerfile so it can be reproduced anywhere.
2- Define the services that make up your app in docker-compose.yml so they can be run together in an isolated environment.
3- Run docker-compose up and Compose will start and run your entire app.
Docker compose file example
version: '3' ---> compose file format version
services: ---> defining one or multiple services definition
db:
image: mysql:5.7 ---> image to be run by the service
volumes:
- db_data: var/lib/mysql --> volume to be used by services
restart: always
web: --->service name
build: .
ports: --> expose ports to the host
- "5000:5000"
volumes:
db_data: ---> Create volume to be used by one or multiple services
Docker Compose Use Case
When you're developing software, the ability to run an application in an isolated environment and interact with it is crucial.
The Compose file provides a way to document and configure all of the application's service dependencies (databases,queues, caches, web service APIs,etc)
Docker Compose Quickstart
There are 3 step process:
1- Define your app's environment with a Dockerfile so it can be reproduced anywhere.
2- Define the services that make up your app in docker-compose.yml so they can be run together in an isolated environment.
3- Run docker-compose up and Compose will start and run your entire app.
Docker compose file example
version: '3' ---> compose file format version
services: ---> defining one or multiple services definition
db:
image: mysql:5.7 ---> image to be run by the service
volumes:
- db_data: var/lib/mysql --> volume to be used by services
restart: always
web: --->service name
build: .
ports: --> expose ports to the host
- "5000:5000"
volumes:
db_data: ---> Create volume to be used by one or multiple services