Docker: Docker Compose v2
7 Docker commands: Docker Compose v2. Click a command to see what each part does.
Docker: Docker Compose v2Index
- Whole sheet120
- Basics: images & containers11
- Volumes & networks4
- Find & inspect containers7
- Environment variables & container config12
- Software versions inside containers & images9
- Logs & shells5
- Run containers3
- Images4
- Cleanup6
- Docker Compose v27
- Container lifecycle & live changes10
- Builds, multi-platform & moving images11
- Volumes, networks & remote hosts in depth12
- Compose: more commands9
- Swarm mode10
Docker Compose v27
docker compose up -d --buildBuild and start everything in the backgroundWhat each part does
docker composeCompose v2 (plugin; not the old docker-compose binary)upcreate and start the services-ddetached--buildbuild images before starting
docker compose up -d --force-recreate --remove-orphans --waitRecreate cleanly and wait until healthyWhat each part does
--force-recreaterecreate containers even if nothing changed--remove-orphansremove containers for services no longer in the file--waitwait until services are running/healthy (implies -d)
docker compose logs -f --tail 100 <service>Follow logs of one serviceWhat each part does
logs <service>logs of that service (omit for all)-ffollow--tail 100start from the last 100 lines
docker compose exec <service> sh; docker compose run --rm <service> <cmd>Shell into a service / run a one-off taskWhat each part does
exec <service> shshell in the already-running service containerrun --rm <service> <cmd>start a new temporary container for a one-off command, removed afterwards
docker compose -f compose.yaml -f compose.prod.yaml -p <project> up -dUse several compose files and a project nameWhat each part does
-f compose.yaml -f compose.prod.yamlmerge files in order; later files override earlier ones-p <project>project name (prefix for container/network names)
docker compose configSee the final merged configWhat each part does
configparse, merge and print the effective compose file (great for checking env substitution)
docker compose down -vStop and remove the stack (and its volumes)DestructiveWhat each part does
downstop and remove containers and networks-valso remove named volumes declared in the file: deletes data
Nothing matches.
My DevOps Playbook by Angelo John Calleja