9.4 Compose Commands
A focused guide to Compose Commands, connecting core concepts with practical Docker and container operations.
Compose commands are the various subcommands the docker compose CLI provides for managing a multi-container application's full lifecycle, covering everything from initial startup through ongoing inspection and management to eventual teardown.
Commands Covering the Application Lifecycle
A core set of commands handles starting, stopping, and removing an application's services.
docker compose up -d
docker compose stop
docker compose start
docker compose down
Commands for Inspecting Running Services
Other commands provide visibility into what's currently running and how it's behaving.
docker compose ps
docker compose logs -f api
docker compose top
Commands for Building and Updating Images
Build-related commands construct or refresh the images a Compose application's services rely on.
docker compose build
docker compose pull
Commands for Interacting With a Running Service
Certain commands provide direct interaction with a specific running service, similar to their equivalent docker CLI counterparts.
docker compose exec api sh
docker compose run --rm api npm run migrate
The run command starts a new, one-off container for a service to execute a specific command, distinct from exec, which runs a command inside an already-running service's container.
Why Compose Commands Matter
This comprehensive set of commands gives Compose its practical usefulness as a complete tool for managing a multi-container application's entire lifecycle, replacing what would otherwise require remembering and correctly combining many individual docker commands targeting each container separately.