Skip to content
Search

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

$ docker swarm 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

$ docker swarm init

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
$ docker swarm init --advertise-addr 0.0.0.0:9999

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

docker swarm leave

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:

docker run ... -e constraint:node==node1 ...

This would start the container on node1.

Checking the Docker Swarm configuration

docker node ls

Container orchestration

Tools

See also

Favorite site

Guide

References


  1. Container-orchestration-with-docker-swarm.pdf ↩

  2. Zero-downtime-docker-deployment.pdf ↩

  3. Sauru.so_-_getting-started-with-docker-swarm.pdf ↩

  4. Sauru.so_-_high-availability-of-docker-swarm.pdf ↩

  5. Sauru.so_-_run-a-service-on-docker-swarm.pdf ↩

  6. Sauru.so_-_little-more-about-docker-swarm.pdf ↩

author Zer0 sitemap