docker-swarm
Skill1 starsChanged 5 months agoMITView on GitHub
Use this skill for Docker Swarm — stack deployment with docker-compose files, immutable config/secret versioning pattern for rolling updates, service constraints and placement, overlay networks, and Swarm maintenance. Activate for docker stack, docker service, or docker swarm commands.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- TheDecipherist/claude-code-mastery-project-starter-kittheir own version, first seen Jun 26, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- TheDecipherist/claude-code-mastery-project-starter-kit★ 338same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository20 other files it gives its agents.
- cad-designSkill
- cloudflare-tunnelSkill
- context-engineeringSkill
- create-branchSkill
- create-releaseSkill
- digital-fabricationSkill
- grafana-prometheusSkill
- k3s-kubernetesSkill
- linux-server-adminSkill
- merge-prSkill
- mikrotik-routerosSkill
- network-engineerSkill
- nextjs-deploymentSkill
- open-projectSkill
- open-prSkill
- proxmox-homelabSkill
- pr-reviewSkill
- python-fastapiSkill
- thai-dev-workflowSkill
- wireguard-vpnSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 215
Manager quorum: always maintain odd number of managers (1, 3, 5).
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Docker Swarm
Stack Deployment
# Deploy or update stack
docker stack deploy -c stack.yml mystack --with-registry-auth
# List stacks and services
docker stack ls
docker stack services mystack
docker stack ps mystack # tasks (containers) per service
# Remove stack
docker stack rm mystackCompose File for Swarm
version: "3.8"
services:
app:
image: registry.local:5000/myapp:1.0.0
deploy:
replicas: 2
placement:
constraints:
- node.role == worker
- node.hostname == prod-server
update_config:
parallelism: 1
delay: 10s
failure_action: rollback
restart_policy:
condition: on-failure
max_attempts: 3
ports:
- target: 3000
published: 3000
mode: ingress # Swarm load-balanced ingress
networks:
- mynet
environment:
- APP_ENV=production
configs:
- source: app-config-v1
target: /app/config.json
secrets:
- source: db-password-v1
target: /run/secrets/db_password
configs:
app-config-v1:
external: true
secrets:
db-password-v1:
external: true
networks:
mynet:
driver: overlay
attachable: trueImmutable Config/Secret Versioning Pattern
Problem: Swarm configs and secrets are immutable — you can't update the content. Changing the stack file to reference a new version forces a rolling update.
Pattern — always version with a suffix:
# Create new config version
docker config create app-config-v2 ./config.json
# Update stack file to reference v2
sed -i 's/app-config-v1/app-config-v2/' stack.yml
# Redeploy (rolling update triggered automatically)
docker stack deploy -c stack.yml mystack
# Clean up old version after all tasks updated
docker config rm app-config-v1Secrets (same pattern):
echo "new-secret-value" | docker secret create db-password-v2 -
# Update stack.yml: db-password-v1 → db-password-v2
docker stack deploy -c stack.yml mystack
docker secret rm db-password-v1Automation helper:
#!/bin/bash
CONFIG_NAME="app-config"
VERSION=$(date +%Y%m%d%H%M%S)
NEW_NAME="${CONFIG_NAME}-${VERSION}"
docker config create "$NEW_NAME" ./config.json
sed -i "s|${CONFIG_NAME}-[0-9]*|${NEW_NAME}|g" stack.yml
docker stack deploy -c stack.yml mystack
echo "Deployed with $NEW_NAME"Service Management
# Force update (trigger rolling restart without image change)
docker service update --force mystack_app
# Scale a service
docker service scale mystack_app=4
# Update image
docker service update --image registry.local:5000/myapp:1.1.0 mystack_app
# Rollback a service
docker service rollback mystack_app
# Get service logs
docker service logs mystack_app --tail=100 -f
# Inspect task failures
docker service ps mystack_app --no-trunc # shows error messagesPlacement Constraints
deploy:
placement:
constraints:
- node.role == manager # only on manager nodes
- node.role == worker # only on worker nodes
- node.hostname == prod-server # specific host
- node.labels.gpu == true # custom node labelAdd custom label to node:
docker node update --label-add gpu=true NODE_ID
docker node ls # get NODE_IDOverlay Networks
# Create overlay network manually
docker network create --driver overlay --attachable mynet
# Inspect network
docker network inspect mynet
# Services on same overlay network can reach each other by service name
# e.g., http://mystack_db:5432 from mystack_appConfigs and Secrets Management
# Create
docker config create myconfig ./config.json
echo "secret-value" | docker secret create mypassword -
# List
docker config ls
docker secret ls
# Inspect (content only visible at creation time for secrets)
docker config inspect --pretty myconfig
# Remove (only if not used by any service)
docker config rm myconfig
docker secret rm mypasswordSecret file in container: mounted at /run/secrets/SECRET_NAME. Read via:
with open("/run/secrets/db_password") as f:
password = f.read().strip()Swarm Cluster Management
# Initialize swarm
docker swarm init --advertise-addr NODE_IP
# Get join tokens
docker swarm join-token worker # for worker nodes
docker swarm join-token manager # for manager nodes (add carefully)
# List nodes
docker node ls
# Remove a node
docker node update --availability drain NODE_ID # gracefully drain tasks
docker swarm leave --force # run on the node itself
docker node rm NODE_ID # run on manager
# Promote/demote manager
docker node promote NODE_ID
docker node demote NODE_IDManager quorum: always maintain odd number of managers (1, 3, 5). Losing majority = cluster freezes. For homelab: 1 manager is fine; for HA: 3 managers minimum.
Registry Authentication
# Login to private registry
docker login registry.local:5000
# Deploy with registry auth (reads from ~/.docker/config.json)
docker stack deploy -c stack.yml mystack --with-registry-authTroubleshooting
# Why is a service not running?
docker service ps mystack_app --no-trunc
# Task inspect (failed task detail)
docker inspect TASK_ID
# Node resource availability
docker node inspect NODE_ID --pretty
# Service didn't update after config change
docker service update --force mystack_app # force re-pull + restart
# Container won't start (config/secret not found)
docker config ls # verify config name matches stack.yml exactlyCommon mistakes:
| Problem | Cause | Fix |
| Config update has no effect | Configs are immutable | Create new version, update stack.yml, redeploy |
Service stuck at Preparing | Image not found in registry | docker pull on node manually, check auth |
| Overlay network unreachable | Firewall blocking VXLAN 4789/udp | Allow UDP 4789 between all Swarm nodes |
| Task constantly fails | Bad config/secret mount | docker service ps --no-trunc for error message |
| Port not accessible | Swarm routing mesh only works on published ports | Verify mode: ingress and host firewall |
Production Checklist
- Image tags are never
latest— use versioned tags for rollback. - Configs and secrets follow versioning pattern (never edit in place).
update_config.failure_action: rollbackon all production services.restart_policy.max_attempts: 3to avoid infinite crash loops.- Deploy node labels for placement; never rely on hostname alone (hostnames change).
- Overlay networks use
attachable: trueonly if you need manual container attachment.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

