How docker/compose works
Docker Compose is a Docker CLI plugin for defining and operating multi-container applications from Compose files. The principal workflow is: a user supplies a Compose model and runs docker compose up; the CLI loads project configuration, then the Compose runtime creates and starts its services through the Docker Engine, with progress and results displayed to the user. The repository also supports lifecycle commands, builds and image operations, logs and interactive container operations, file watching, provider plugins, and relay services. Several command implementations are unsampled, so uncertain runtime links are dashed.
Main entry points: compose/compose.go Compose service runtime · compose/compose.go CLI commands · projectloader Project loading · convert.go Model conversion
Components 22
CLI and display
- CLI commands
cmd/compose/compose.go - Progress display
cmd/display/tty_layout.go - Output formatting
cmd/formatter/shortcut.go
Project modeling
- Project loading
internal/projectloader - Model conversion
pkg/bridge/convert.go - Service dependencies
internal/depgraph/depgraph.go
Compose runtime
- Compose service runtime
pkg/compose/compose.go - Service planning
pkg/compose/plan.go - State reconciliation
pkg/compose/reconcile.go - Container lifecycle
pkg/compose/service_containers.go - File watching
pkg/compose/watch.go
Container and image operations
- Image building
pkg/compose/build.go - Image operations
internal/images/images.go - OCI registry operations
internal/oci/push.go - Container utilities
internal/containerops/cp.go - Logs and attach
internal/logstream/attach_service.go
Extensions and integrations
- Provider plugins
internal/provider/plugins.go - Network relay
internal/relay/relay.go - Desktop integration
internal/desktop/client.go - Dry-run client
pkg/dryrun/dryrunclient.go
Other components
- Compose user
- Docker Engine
Connections 21
- Compose user → CLI commands: runs command
README.md - CLI commands → Project loading: loads model
- Project loading → Model conversion: converts model
- Model conversion → Service dependencies: resolves dependencies
- CLI commands → Compose service runtime: dispatches operation
- Compose service runtime → Service planning: plans services
- Compose service runtime → State reconciliation: reconciles state
- Compose service runtime → Container lifecycle: manages containers
- Compose service runtime → Image building: builds images
- Compose service runtime → Image operations: operates on images
- Compose service runtime → OCI registry operations: pushes images
- Compose service runtime → File watching: watches files
- CLI commands → Container utilities: dispatches utilities
- CLI commands → Logs and attach: dispatches logs
- Compose service runtime → Docker Engine: uses engine backend
- Container lifecycle → Docker Engine: creates containers
- Compose service runtime → Progress display: reports progress
- CLI commands → Output formatting: configures output
cmd/compose/compose.go - Provider plugins → Network relay: ensures relay
internal/provider/plugins.go - Desktop integration → Docker Engine: connects locally
- CLI commands → Dry-run client: uses dry-run client