Docker Compose is used to start up multiple Docker containers at the same time from a single configuration file.
compose.yaml
A default network is automatically created for all composed containers, meaning every container is added to that network by default.All configurations in
compose.yaml mirror options available in the docker run command. The examples below use Docker Compose v2 syntax — some v1 syntax is deprecated.- To use
-itinteractivity, add both of these fields to the service:stdin_open: true— Keep an open input connectiontty: true— Attach this terminal
- To override the Dockerfile
ENTRYPOINT, specifyentrypointincompose.yaml.
Commands
Use
docker compose (v2) instead of the deprecated docker-compose (v1).List containers
Build or rebuild containers
Builds containers without starting them.Create and start containers
up = build/rebuild + start
Execute a command in a running service
By default, allocates a TTY so you get an interactive prompt immediately.Display service log output
Stop services
Stops running containers without removing them. Restart withdocker compose start.