Read the docker compose command reference or run docker
compose help for a complete list of commands and options.
Docker Compose
Learn the basics of Docker Compose, a tool for defining and running multi-container applications.
Recommended reading
The Docker Compose command line
Docker Compose is also a Docker subcommand. Based on a Compose file, it can:
- Start, stop, and rebuild services:
- View the status of running services:
- Stream the log output of running services:
Other Compose concepts
Networks are the layer that allow services to communicate with each other. Compose lets you configure named networks that can be reused across multiple services for greater control and security.
Volumes are persistent data stores implemented by the container engine. Compose offers a neutral way for services to mount volumes, and configuration parameters to allocate them to infrastructure.
You will use these concepts in the following exercise.
Going further
The following tools are (completely) out of scope for this course, but interesting to learn about if you want to go further with Docker:
- Traefik and Caddy are reverse proxies developed to integrate with microservices such as Docker Compose services. Using it, you can get rid of nginx and its site configuration files. For example, Traefik can interrogate the Docker Daemon about running containers and configure itself automatically.
-
Docker Swarm can network a cluster of Docker engines together across multiple servers, allowing you to aggregate separate machines into one giant pool of resources. You can then simply deploy Compose services to the swarm and containers will be automatically spawned on one of the clusterβs machines.
With a swarm, you can also use more advanced Compose features like:
- Configs allow services to adapt their behaviour without the need to rebuild a Docker image. Services can only access configs when explicitly granted in the Compose file. Configs are mounted as files into the file system of a serviceβs container.
- Secrets are a flavor of Configs focusing on sensitive data, with specific constraint for this usage. Services can only access secrets when explicitly granted in the Compose file. Secrets are either read from files or from the environment.
- If you want to go even further into large-scale Docker deployments, look at Kubernetes, an open-source system for automating deployment, scaling, and management of containerized applications. It groups containers that make up an application into logical units for easy management and discovery.