Docker:Swarm
lastmod 2026-03-25created 2016-05-3122 edits
Current versions of Docker include swarm mode for natively managing a cluster of Docker Engines called a swarm. Use the Docker CLI to create a swarm, deploy application services to a swarm, and manage swarm behavior.
Display and rotate the root CA
If the swarm has not been initialized, the following message is printed.
Error response from daemon: This node is not a swarm manager. Use "docker swarm init" or "docker swarm join" to connect this node to swarm and try again.
You need to initialize (docker swarm init or join a swarm docker swarm join.
Initialize a swarm
On successful initialization, the following is printed.
Swarm initialized: current node (4mu50fuj9paosdcor6sjsi4bp) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-67muwgaig1jyfnpzmyn2yj55o2fcxx1awlrta28ssgwgf9v25i-aal0nt4ytluxowo8g70malidi 192.168.70.21:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
On the PC that you want to join the swarm, copy and run the docker swarm join ... command printed above.
docker swarm join --token SWMTKN-1-67muwgaig1jyfnpzmyn2yj55o2fcxx1awlrta28ssgwgf9v25i-aal0nt4ytluxowo8g70malidi 192.168.70.21:2377
Advertise address (advertise addr)
Join a swarm as a node and/or manager
docker swarm join --token SWMTKN-1-67muwgaig1jyfnpzmyn2yj55o2fcxx1awlrta28ssgwgf9v25i-aal0nt4ytluxowo8g70malidi 192.168.70.21:2377
Leave the swarm
How to select a node in Swarm
Take a look at the Swarm filter docs. You can set various constraints on what node Swarm should pick for any given container. For your case try something like:
This would start the container on node1.
Checking the Docker Swarm configuration
Container orchestration
Tools
See also
Favorite site
- Docker Swarm vs. Kubernetes
- About Docker Swarm (ko)
- Docker Swarm: A brief introduction to Docker Swarm and installation guide
- arisu1000.tistory.com: Docker Swarm
- [Recommended] Slideshare: Open Source Consulting: Docker on Cloud(Digital Ocean)
- Docker Swarm
- Presentation on Machine, Swarm, and Compose for Orchestration
- DevOps with Docker
- A DevOps environment for startups - Docker infrastructure
- [Recommended] Easy and fast distributed server management with Docker Swarm 1
- [Recommended] Zero-downtime deployment of web services with Docker 2