Docker Compose
$ docker-compose Official Med RiskDocker Compose (docker-compose / docker compose) orchestrates multi-container stacks from compose.yaml. Compose v2 adds agent-friendly --dry-run, canonical config --format json, structured ps --format json, --progress json, and --ansi never flags.
brew install docker-compose Direct docker-compose / docker compose execution gives native --dry-run, config --format json, and scoped log tailing without MCP translation.
Agent-Readiness Checklist
Local Probe EvidenceCaptured --help excerpt
Usage: docker compose [OPTIONS] COMMAND
Define and run multi-container applications with Docker
Options:
--all-resources Include all resources, even those not
used by services
--ansi string Control when to print ANSI control
characters ("never"|"always"|"auto")
(default "auto")
--compatibility Run compose in backward compatibility mode
--dry-run Execute command in dry run mode
--env-file stringArray Specify an alternate environment file
-f, --file stringArray Compose configuration files
--parallel int Control max parallelism, -1 for
unlimited (default -1)
--profile stringArray Specify a profile to enable
--progress string Set type of progress output (auto,
tty, plain, json, quiet)
--project-directory string Specify an alternate working directory
(default: the path of the, first
specified, Compose file)
-p, --project-name string Project name
Management Commands:
bridge Convert compose files into another model
Commands:
attach Attach local standard input, output, and error streams to a service's running container
build Build or rebuild services
commit Create a new image from a service container's changes
config Parse, resolve and render compose file in canonical format
cp Copy files/folders between a service container and the local filesystem
create Creates containers for a service
down Stop and remove containers, networks
events Receive real time events from containers
exec Execute a command in a running container
export Export a service container's filesystem as a tar archive
images List images used by the created containers
kill Force stop service containers
logs View output from containers
ls List running compose projects
pause Pause services
port List port mappings or print the public port for a spec FCRS-1.0 6-Dimension Breakdown
Compose v2 natively provides --format json on config and ps, --progress json, --ansi never, and global --dry-run.
docker-compose config --format jsonandps --format jsonemit valid JSON--ansi neverand--progress jsoneliminate TTY escape noise
Supports --dry-run across lifecycle commands and config validation, though down -v can permanently delete volumes.
- Global
--dry-runflag previews mutations without executing them down -vdestroys named data volumes if passed carelessly
Single Go binary/plugin on macOS, Linux, and Windows, requiring a running Docker/Colima/OrbStack daemon.
- Distributed via Homebrew, Docker Desktop, and GitHub Releases
Standard multi-container local stack runner with scoped service exec, log tailing, and profile support.
- Handles build, up, ps, logs, and exec for multi-service stacks
Official Docker Compose v2 project (docker/compose) under Apache-2.0.
- Official
docker/composerepository
Extensive official Compose CLI reference and --help output.
- Official docs at docs.docker.com/reference/cli/docker/compose/
Security, Auth & Guardrails
Uses local Docker socket (DOCKER_HOST) and registry credentials stored in ~/.docker/config.json.
Apache-2.0 open-source CLI; Docker Desktop licensing applies only to Docker Desktop GUI/VM in larger organizations.
# Docker Compose Agent Rules - Run `docker-compose config --format json` and `docker-compose --dry-run up -d` before starting services. - Always pass `--ansi never` (and `--tail=100` on `logs`) in non-TTY agent runs. - Never run `docker-compose down -v` without explicit confirmation, as `-v` deletes named volumes.
Agent-Ready Command Recipes
Safe Read-Only Queries
docker-compose config --format json
Expands variables, profiles, and overrides into canonical JSON to catch schema errors read-only.
docker-compose ps --format json
Outputs running and exited service container metadata as structured JSON.
Controlled Writes & Previews
--dry-run docker-compose --dry-run up -d
Pre-evaluates image pulls, network creation, and container lifecycle steps without changing daemon state.
Strengths for Agents
- + Global
--dry-runpreviewsup,down, andpullsteps safely. - + Native
--format jsononconfigandpsplus--ansi neverfor clean parsing. - + Canonical
configresolution catches variable interpolation and YAML mistakes early.
Caveats & Pitfalls
- ! Requires an active Docker-compatible daemon (
DOCKER_HOST) for lifecycle commands. - !
docker-compose down -vpermanently wipes named volumes.