Docker Swarm with Cent OS 7

Recently, I have been trying to set up a Swarm Cluster with Cent OS 7.

However, I met with some connectivity issues between the Swarm Manager and the Consul service discovery container. Using docker logs on the Swarm Manager, I got the following error:

 

In my case, the reason is that Cent OS 7 has an active firewall that disallows remote access to its ports.

The solution was to simply tell the current firewall session on the Docker host running the Consul container to open the 8500 port with the following command:

$ sudo firewall-cmd --zone=public --add-port=8500/tcp

For all other nodes in the cluster, open up port 2375 for the Swarm Managers and Swarm Agents to communicate:

$ sudo firewall-cmd --zone=public --add-port=2375/tcp

These commands only open the ports on the current firewall session – meaning that rebooting the service or host OS will cause these rules to be gone. You can make it permanent by adding the “--permanent” flag to the above commands.

After opening up the ports, list the info of the cluster to check that the Swarm Manager and Agents can communicate properly. A working Swarm cluster should have the following output:

[user@localhost ~]# docker -H :4000 info
Containers: 3
Running: 3
Paused: 0
Stopped: 0
Images: 3
Server Version: swarm/1.2.3
Role: primary
Strategy: spread
Filters: health, port, containerslots, dependency, affinity, constraint
Nodes: 1
localhost.localdomain: 192.168.56.102:2375
└ ID: WQVM:I7YW:SDEN:M2SJ:ZHSP:ZNSW:OWBY:MEH5:C5M4:IEA7:HDBB:B25U
└ Status: Healthy
└ Containers: 3
└ Reserved CPUs: 0 / 3
└ Reserved Memory: 0 B / 513.6 MiB
└ Labels: executiondriver=, kernelversion=3.10.0-327.18.2.el7.x86_64, operatingsystem=CentOS Linux 7 (Core), storagedriver=devicemapper
└ UpdatedAt: 2016-06-01T07:34:32Z
└ ServerVersion: 1.11.1
Plugins:
Volume:
Network:
Kernel Version: 3.10.0-327.18.2.el7.x86_64
Operating System: linux
Architecture: amd64
CPUs: 3
Total Memory: 513.6 MiB
Name: da7787e4bc06
Docker Root Dir:
Debug mode (client): false
Debug mode (server): false
WARNING: No kernel memory limit support

Advertisements

One thought on “Docker Swarm with Cent OS 7

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s