You're probably familiar by now what Docker is. If you're new around here, Docker is a container platform similar to LXC. Docker Swarm is an container orchestration tool similar to Kubernetes.


  • 3 Linux virtual machines (I'm using CentOS 7)

Installing Docker

The first step is to install Docker on all three VMs. I'm using the community edition of docker. Official installation instructions are found here.

  1. Verify Docker is not installed, if it is installed; uninstall it.
yum remove docker \
	docker-client \
	docker-client-latest \
	docker-common \
	docker-latest \
	docker-latest-logrotate \
	docker-logrotate \

2. Add the Docker Community Edition repo.

yum install -y yum-utils \
	device-mapper-persistent-data \
yum-config-manager \
	--add-repo \

3.  Install Docker-CE and containerd

yum install docker-ce docker-ce-cli

4. Start and Enable Docker

systemctl start docker && systemctl enable docker

Creating the Swarm

  1. Open the following ports on all three VMs:
    firewall-cmd --add-port=2376/tcp --permanent
    firewall-cmd --add-port=2377/tcp --permanent
    firewall-cmd --add-port=7946/tcp --permanent
    firewall-cmd --add-port=7946/udp --permanent
    firewall-cmd --add-port=4789/udp --permanent

2. Select a VM to be the swarm manager.

This will be the boss of the swarm and other nodes will need to be joined to it to join the swarm. ( is the IP of the manager VM)

docker swarm init --advertise-addr

When you execute the command above it will return join token that will be needed on the other nodes. Copy and paste it over to the other VMs.

docker swarm join --token SWMTKN-1-2chtxjrd2mwh15a4fmsxq57vc434dz6nu0netl6zxf7zyepft4-71ky4qhc29e5o1f6khrcyatgs

3. Verify all of the nodes have been added to the swarm with the docker node ls command.

You will see an output like below.

ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS      ENGINE VERSION
p8x50smdaxvya9vvjs6edx52o     dck-wrk-01          Ready                Active                                  19.03.1
tuy7osgda5dfa9vabez1edx5i     dck-wrk-02          Ready                Active                                  19.03.1
ryu4iqx27q4ckakpvqqk8nvsh *   dck-mgr-01          Ready                Active              Leader              19.03.1

Yay the swarm is up and running!