DevOps/Docker/docker compose

From Wikiversity
< DevOps‎ | Docker
Jump to navigation Jump to search

Docker Compose[1] is a tool available since 2014 for defining and running multi-container Docker applications.

Rules are defined in docker-compose.yml and executed by running docker-compose up.

docker-compose allows to define start order dependencies between containers.

For reference of valid options for docker compose check:

Installation[edit | edit source]

  • brew install docker-compose

Basic commands[edit | edit source]

  • docker-compose -h (for list of commands and options)
  • docker-compose up
  • docker-compose up -d
-d daemon
  • Start your containers with a command line variable: YOUR_VARIABLE=YOUR_VALUE docker-compose up[2]

  • docker-compose -p NAME --project-name


  • docker-compose logs View output from containers
  • docker-compose logs -f View output from containers
  • docker-compose pull SERVICE_NAME or docker-compose pull


  • docker-compose build
  • docker-compose bundle
  • docker-compose config
  • docker-compose create
  • docker-compose down
docker-compose down --remove-orphans
  • docker-compose events
  • docker-compose exec
  • docker-compose help
  • docker-compose images
  • docker-compose kill
  • docker-compose logs[4]: docker-compose logs SERVICE_NAME (You will find your SERVICE_NAME looking into your docker-compose.yml file)
  • docker-compose pause
  • docker-compose port
  • docker-compose ps
  • docker-compose pull[5].docker-compose pull SERVICE_NAME. Just pull container images but do not start them. To update your image and start your services: docker-compose pull && docker-compose up -d
  • docker-compose push
  • docker-compose restart
  • docker-compose rm
  • docker-compose run
  • docker-compose scale
  • docker-compose start
  • docker-compose stop
  • docker-compose top
  • docker-compose unpause
  • docker-compose up

Docker compose file: docker-compose.yml[edit | edit source]

Activities[edit | edit source]

Basic[edit | edit source]

  1. Read docker-compose StackOverflow questions:
  2. Read docker-compose changelog:
  3. Review docker compose file format evolution

Advanced[edit | edit source]

  1. Read docker-compose source code:
  2. Read Ansible module documentation about docker_compose:
  3. Learn to use extension-fields[6] or templating added in 3.4 version. [7]

See also[edit | edit source]

References[edit | edit source]