
Docker Swarm
Deploy a production-style Docker Swarm stack with replicas, rollbacks, healthchecks, configs, and secrets.
Overview
Docker Swarm is an agent skill for the Operate phase that provides a production-ready Docker Swarm stack template for replicated web and API services with updates, healthchecks, configs, and secrets.
Install
npx skills add https://github.com/pluginagentmarketplace/custom-plugin-docker --skill docker-swarmWhat is this skill?
- swarm-stack.yaml version 3.8 with docker stack deploy workflow
- Web service: 3 replicas, start-first updates, rollback on failure, CPU and memory limits
- API service: 2 replicas with database network segmentation
- Healthchecks on web (wget spider /health) with interval, timeout, and retries
- Configs and secrets mounts for nginx TLS and database credentials
- Compose file version 3.8
- Web deploy replicas: 3; API deploy replicas: 2
- Healthcheck interval 30s, timeout 10s, retries 3
Adoption & trust: 1 installs on skills.sh; 2 GitHub stars; 1/3 security scanners passed (skills.sh audits); trending (+100% hot-view momentum).
What problem does it solve?
You have container images but no battle-tested Swarm compose file for replicas, rollbacks, and secret wiring on real nodes.
Who is it for?
Indie operators running Docker Swarm on a few Linux workers who want nginx plus API patterns out of the box.
Skip if: Teams on managed Kubernetes, serverless-only deploys, or local docker-compose dev with no Swarm cluster.
When should I use this skill?
When deploying or hardening a multi-service app on Docker Swarm using a production stack file.
What do I get? / Deliverables
You deploy a named stack with defined replica counts, failure rollback behavior, and network segmentation ready to customize for your cluster.
- swarm-stack.yaml stack definition
- Service replica, update, and rollback policies
- Network, config, and secret wiring pattern for web and API tiers
Recommended Skills
Journey fit
Swarm stack operations are ongoing production infrastructure work after the app is built and shipped. The artifact is a version 3.8 stack file for replicated services, placement constraints, and resource limits on worker nodes.
How it compares
Swarm stack template skill, not an MCP server or single-container dev compose snippet.
Common Questions / FAQ
Who is docker-swarm for?
Solo builders and tiny ops teams self-hosting with Docker Swarm who need a starting production stack rather than writing deploy YAML from scratch.
When should I use docker-swarm?
In Operate infra when promoting containerized web and API services to a Swarm cluster with healthchecks, rolling updates, and secrets.
Is docker-swarm safe to install?
It is declarative YAML referencing images and secrets; review the Security Audits panel on this page and replace example images and credentials before production.
SKILL.md
READMESKILL.md - Docker Swarm
# Production-Ready Docker Swarm Stack # Version: 1.0.0 # Deploy: docker stack deploy -c swarm-stack.yaml myapp version: '3.8' services: web: image: nginx:alpine ports: - "80:80" - "443:443" networks: - frontend - backend deploy: mode: replicated replicas: 3 update_config: parallelism: 1 delay: 10s failure_action: rollback order: start-first rollback_config: parallelism: 1 delay: 10s restart_policy: condition: on-failure delay: 5s max_attempts: 3 window: 120s placement: constraints: - node.role == worker resources: limits: cpus: '0.5' memory: 256M reservations: cpus: '0.25' memory: 128M healthcheck: test: ["CMD", "wget", "-q", "--spider", "http://localhost/health"] interval: 30s timeout: 10s retries: 3 start_period: 10s configs: - source: nginx_config target: /etc/nginx/nginx.conf secrets: - ssl_certificate - ssl_key api: image: myapp/api:latest networks: - backend - database environment: - DATABASE_URL=postgres://db:5432/myapp deploy: mode: replicated replicas: 2 update_config: parallelism: 1 delay: 10s resources: limits: cpus: '1' memory: 512M secrets: - db_password - api_key db: image: postgres:15-alpine networks: - database environment: - POSTGRES_DB=myapp - POSTGRES_USER=app - POSTGRES_PASSWORD_FILE=/run/secrets/db_password volumes: - db_data:/var/lib/postgresql/data deploy: mode: replicated replicas: 1 placement: constraints: - node.role == manager resources: limits: memory: 1G secrets: - db_password networks: frontend: driver: overlay backend: driver: overlay internal: true database: driver: overlay internal: true volumes: db_data: driver: local configs: nginx_config: file: ./nginx.conf secrets: db_password: external: true ssl_certificate: external: true ssl_key: external: true api_key: external: true # Docker Swarm Guide ## Quick Start ### Initialize Swarm ```bash docker swarm init --advertise-addr <MANAGER-IP> ``` ### Join Nodes ```bash # Get worker token docker swarm join-token worker # Get manager token docker swarm join-token manager ``` ### Deploy Stack ```bash docker stack deploy -c docker-compose.yml myapp ``` ## Service Management ### Create Service ```bash docker service create --name web --replicas 3 -p 80:80 nginx ``` ### Scale Service ```bash docker service scale web=5 ``` ### Update Service ```bash docker service update --image nginx:latest web ``` ### Rollback ```bash docker service rollback web ``` ## Monitoring ### View Services ```bash docker service ls ``` ### View Tasks ```bash docker service ps web ``` ### View Logs ```bash docker service logs -f web ``` ## Secrets Management ### Create Secret ```bash echo "mypassword" | docker secret create db_password - ``` ### Use in Service ```bash docker service create --secret db_password myapp ``` ## Best Practices 1. **Use 3+ managers** for high availability 2. **Drain nodes** before maintenance 3. **Use placement constraints** for data services 4. **Set resource limits** on all services 5. **Use health checks** for automatic recovery 6. **Overlay networks** for service isolation ## Common Commands | Command | Description | |---------|-------------| | `docker node ls` | List nodes | | `docker service ls` | List services | | `docker stack ls` | List stacks | | `docker node update --availability drain NODE` | Drain node | | `docker swarm leave --force` | Leave swarm | #!/bin/bash # Docker Swarm Cluster Initialization Script # Usag