docker swarm initStarts the control plane and prints worker join instructions.
Swarm cluster, node, service, and stack commands for container orchestration on Docker Engine.
Initialize and manage a Docker Swarm cluster.
docker swarm initStarts the control plane and prints worker join instructions.
Initialize swarm and advertise a specific manager IP.
docker swarm init --advertise-addr 10.0.0.10Important on hosts with multiple interfaces.
docker swarm join-token workerUse the printed command on worker nodes.
docker swarm join-token managerUse carefully since managers have control plane privileges.
docker swarm join --token <token> 10.0.0.10:2377Run this on a worker or manager being added to the cluster.
docker swarm leaveUse `--force` carefully on a manager.
docker node lsShows manager status, availability, and health.
docker node inspect selfUseful for labels, availability, and TLS info.
docker node update --label-add zone=us-east-1a worker-1Labels are useful for placement constraints.
docker node update --availability drain worker-1Useful before maintenance or draining workloads.
Create, inspect, scale, and update services in a swarm.
docker service create --name web -p 8080:80 nginx:latestThis is the main swarm service deployment primitive.
docker service lsShows replica state and image references.
docker service ps webUseful for troubleshooting placement and task failures.
docker service inspect webInspect update config, rollback policy, labels, and networking.
docker service scale web=5Can scale multiple services in one command too.
docker service update --image nginx:1.27 webSwarm performs a rolling update based on service update settings.
docker service update --env-add LOG_LEVEL=debug webUseful for changing config without redefining the service from scratch.
docker service update --publish-add 8443:443 webUseful for incremental service exposure changes.
docker service rollback webUseful after a failed rolling update.
docker service rm webStops and cleans up all tasks of that service.
docker stack deploy -c compose.yaml mystackA convenient higher-level workflow for multi-service swarm apps.
docker stack lsUseful for multi-application swarm clusters.
docker stack services mystackHelpful for per-application troubleshooting.
docker stack ps mystackUseful when diagnosing stack rollout issues.
docker stack rm mystackStops and removes the stack's services and networks.