Docker compose
Write and review Docker Compose files with consistent best practices and conventions (file naming, override strategy, service naming, key ordering, env handling, ports, and healthchecks). Use when creating or standardizing compose.yaml/docker-compose.yml.From its SKILL.md
npx -y skills add nbsp1221/agent-skills --skill docker-composeAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
3.7 KB, 805 tokens by cl100k_base, as published. Nobody here has run it
Docker Compose
Opinionated conventions for consistent, maintainable Docker Compose files.
Best Practices
File naming and override strategy
- Prefer
compose.yaml(orcompose.yml) as the canonical base file. - Keep local-only changes in
compose.override.yaml(auto-merged by Compose).- If an override file is local-only, add it to
.gitignoreunless the team explicitly wants it committed (optionally keep a.examplefile).
- If an override file is local-only, add it to
- For environment-specific configs, use
compose.<env>.yamland combine with-f. - Avoid the top-level
versionkey (obsolete).
Service naming and identity
- Use kebab-case service names; they become internal DNS names.
- Avoid
container_nameunless strictly required; it prevents scaling. - Pin image tags (avoid
latest); prefer digests for production.
Env var conventions
- Use
.envfor interpolation,env_filefor container runtime values. - Keep secrets out of Compose files; commit
.env.exampleonly. - Prefer mapping style for
environmentwhen values include special chars. - If the same variable is set in both,
environmentoverridesenv_file(key order does not change behavior).
Ports, volumes, and paths
- Quote
HOST:CONTAINERport mappings to avoid YAML base-60 parsing issues. - Prefer relative bind mounts starting with
./. - Use named volumes for persistent data.
Readiness and dependencies
- Use
depends_onfor ordering; addhealthcheckandcondition: service_healthyfor readiness-sensitive dependencies.
Profiles for optional services
- Use
profilesto gate optional services (e.g., debug, seed, admin) instead of maintaining separate files. - If a service is profile-gated, any
depends_ontargets must be in the same profile or always enabled; otherwise the model is invalid.
Project naming and file composition
- Set top-level
namewhen you need stable project identifiers (network/volume names) across directories or CI. - Use
include/fragmentsto split large Compose files, but only if your Compose implementation supports them.
DRY with extensions and anchors
- Use
x-extension fields plus YAML anchors/merge to share repeated blocks (env, volumes, labels) across services.
Secrets and configs
- Declare
secrets/configsat top level and explicitly grant access per service; top-level declaration alone is not enough. - Prefer
secrets/configsfor sensitive or shared files when the platform supports them.
Deploy portability
- Treat
deployas platform-specific; some Compose implementations ignore it in local runs. - Document when
deployis required so users do not assume it applies everywhere.
Init for PID 1
- Set
init: truefor long-running services to handle PID 1 signal and zombie reaping correctly.
Ordering Conventions
Top-level order
name(optional)servicesnetworksvolumesconfigssecrets
Service key order
Use this exact order for keys within each service to keep the file consistent.
- Identity:
image/build,container_name,hostname - Runtime:
command,entrypoint,restart - Environment:
env_file,environment,labels - Resources:
ports,expose,volumes - Connectivity:
depends_on,networks,network_mode - Health:
healthcheck
Validation
- Always run
docker compose configbefore shipping changes.
References
- For the official specification and detailed semantics, see https://compose-spec.io
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.