Skip to content

Docker compose

Docker Compose is a tool for running multi-container applications on Docker defined using the Compose file format. A Compose file is used to define how the one or more containers that make up your application are configured. Once you have a Compose file, you can create and start your application with a single command: docker compose up.

Warning

Since Docker v [??] the compose command is now a sub-command of docker. It replaces the docker-compose command.

Compose file

The compose file contains the definition of the stack of applications and resources required to run as a unit.

The default filename is docker-compose.yml. The name can be changed, but you need to pass the new name to the compose command using the f option. It is best to retain the docker-compose. prefix in the custom file name.

docker compose [-f docker-compose.staging.yml] up -d

The compose file reference can be found here: https://docs.docker.com/compose/compose-file/compose-file-v3/.

Assignments

Getting started with Docker Compose

Complete the official Getting started with Docker Compose tutorial.

MySQL and phpmyadmin

Create a compose file to run mysql and phpmyadmin together. Use the latest official images and default ports.

The mysql server should have:

  • a test database
  • a test user
  • with password test456

The phpmyadmin server should be configured to have the mysql server as its only host.