Using Docker Compose to define an application - tooltwist/documentation GitHub Wiki

Docker Compose allows a single file to define all the docker containers that need to be running to implement an application.

For example, this docker-compose.yml file defines three images that need to be started up to run the Curia application.

api:
  image: curia-core-image
  links:
  - db
  - redis
  ports:
  - "4000:4000"
  env:
  - "VIRTUAL_HOST=mydomain.com"
  - "VIRTUAL_PORT=8080"
db:
  image: wnameless/mysql-phpmyadmin
  ports:
  - "49161:80"
redis:
  image: redis

A few notes:

  • The links tag allow software in the api container to directly access to the db and redis containers using DNS entries rather than the potentially changing IP addresses. It also allows internal port numbers to be used rather than those servers having to expose ports to the outside world.
  • The ports tag defines ports that need to exposed to the outside world, for example for the web server, and for phpmyadmin.
  • The VIRTUAL_HOST and VIRTUAL_PORT environment variables specify that incoming requests to mydomain.com will be sent to this server at port 8080 (via nginxgen and nginx-proxy).

If a container is required to be built using a Dockerfile, a build definition can replace the image line.

See http://docs.docker.com/compose for full details of using Compose.