Professional Documents
Culture Documents
1 S6: Compose
2 Docker Compose
• Why: configure relationships between containers
• Why: save our docker container run settings in easy-to-read file
• Why: create one-liner developer environment startups
• Comprised of 2 separate but related things
• 1. YAML-formatted file that describes our solution options for:
•containers
•networks
•volumes
• 2. A CLI tool docker-compose used for local dev/test automation with
those YAML files
3 docker-compose.yml
• Compose YAML format has it's own versions: 1, 2, 2.1, 3, 3.1
• YAML file can be used with docker-compose command for local
docker automation or..
• With docker directly in production with Swarm (as of v1.13)
• docker-compose --help
• docker-compose.yml is default filename, but any can be used with
docker-compose -f
4 docker-compose CLI
• CLI tool comes with Docker for Windows/Mac, but separate
download for Linux
• Not a production-grade tool but ideal for local development and test
• Two most common commands are
•docker-compose up # setup volumes/networks and start all
containers
•docker-compose down # stop all containers and remove
cont/vol/net
• If all your projects had a Dockerfile and docker-compose.yml then
"new developer onboarding" would be:
•git clone github.com/some/software
•docker-compose up
5 Assignment: Writing A Compose File
• Build a basic compose file for a Drupal content management system
website. Docker Hub is your friend
• Use the drupal image along with the postgres image
• Use ports to expose Drupal on 8080 so you can localhost:8080
• Be sure to set POSTGRES_PASSWORD for postgres
• Walk though Drupal setup via browser
• Tip: Drupal assumes DB is localhost, but it's service name
• Extra Credit: Use volumes to store Drupal unique data 1
•git clone github.com/some/software
•docker-compose up 8/23/17