Search⌘ K

Docker Compose

Explore how Docker Compose facilitates running multiple Docker containers together in microservice systems. Understand its role in service discovery, load balancing, port mapping, and shared volumes through YAML files. Gain practical knowledge using common Docker Compose commands to build, start, scale, log, and stop services efficiently in a microservice architecture.

Overview #

A typical microservice system contains more than a single Docker container. As explained in chapter 2, microservices are modules of a system.

It would be good to have a way to start and run several containers together for starting all the modules that the system consists of in one go. This can be done with Docker Compose.

Coordinating a system of multiple Docker containers requires more than just starting multiple Docker containers. It also requires configurations for the virtual network with which the Docker containers communicate with each other. In particular, containers must be able to find each other in order to communicate.

In a Docker Compose environment, a service can simply contact another service via a Docker Compose link and then use the service name as the hostname. So it could use a URL like http://order/ to contact the order microservice.

Docker Compose links offer some kind of service discovery, that is, a ...