1.3 KiB
1.3 KiB
Docker Swarm Stack Skill
Use this skill when adding, reviewing, or modifying Docker Swarm stack files in this repository.
Workflow
- Confirm the service belongs in the Swarm repo.
- Create or update a Swarm-compatible stack YAML file.
- Create or update
.env.examplewith placeholders only. - Use Docker secrets/configs for sensitive runtime values.
- Define overlay networks and named volumes explicitly.
- Add
deploy:settings only when they are meaningful. - Validate YAML/Compose rendering where possible.
- Explain deployment commands, required secrets, required networks, and rollback notes.
Swarm Standards
- Use 2-space YAML indentation.
- Prefer explicit image tags over unpinned
latestwhen stability matters. - Use
deploy.restart_policyfor Swarm-managed services. - Use
placement.constraintswhen a service must run on a specific node or node label. - Do not use
container_name; it is ignored or problematic in Swarm. - Be careful with
depends_on; Swarm does not honor Compose startup ordering the same way local Compose does. - Prefer external secrets for sensitive values.
Validation Command Pattern
docker compose --env-file <service>.env.example -f <stack-file>.yml config
Do not run docker stack deploy unless explicitly asked.