Docker Compose Vocabulary
5 exercises — Master the English vocabulary of Docker Compose: file structure, service dependencies, secrets management, volume types, and override patterns.
0 / 5 completed
Quick reference: Docker Compose vocabulary
- Top-level keys — services (required), networks, volumes
- depends_on condition: service_healthy — waits for health check to pass, not just container start
- env_file + .gitignore — standard pattern for dev secrets; never inline in environment: block
- Named volume — persistent, Docker-managed; bind mount — host path, for dev live-reload
- docker-compose.override.yml — automatically merged; holds dev-only differences from the base file
1 / 5
A developer asks: "What are the three primary top-level sections in a docker-compose.yml file, and what does each define?"
Which answer is correct?
The three primary top-level keys are services, networks, and volumes.
A
• services — the core section; each named entry defines a container: its image or build context, environment variables, port mappings, volume mounts, networks, restart policy, health check, and service dependencies
• networks — defines custom Docker networks; if omitted, Compose creates a default bridge network named
• volumes — defines named volumes; if a service references a named volume that isn't listed here, Compose creates it automatically
Optional top-level keys include
Key vocabulary:
• compose.yaml — the Compose file; defines the full multi-container application
• service — a named container workload definition in the Compose file
• named volume — a Docker-managed persistent storage volume defined in the top-level
• top-level key — a root-level section in the Compose YAML (services, networks, volumes, configs, secrets)
A
docker-compose.yml (or compose.yaml) has this structure:• services — the core section; each named entry defines a container: its image or build context, environment variables, port mappings, volume mounts, networks, restart policy, health check, and service dependencies
• networks — defines custom Docker networks; if omitted, Compose creates a default bridge network named
<project>_default• volumes — defines named volumes; if a service references a named volume that isn't listed here, Compose creates it automatically
Optional top-level keys include
configs and secrets — used primarily in Docker Swarm mode for configuration and credential management. The only mandatory section is services.Key vocabulary:
• compose.yaml — the Compose file; defines the full multi-container application
• service — a named container workload definition in the Compose file
• named volume — a Docker-managed persistent storage volume defined in the top-level
volumes section• top-level key — a root-level section in the Compose YAML (services, networks, volumes, configs, secrets)