Configure Portainer with Docker Swarm

Portainer is a nice tool to manage your Docker environment. It supports Docker Swarm and is able to remotely connect to the Docker API.

Before we start, you need create a swarm cluster with portainer running as a service.

You can follow my previous blog post Create a multiple node swarm cluster using Docker Machine in your Mac. Once you have a swarm cluster, you can go continue.

By default, the Docker API is secured and TLS is enabled. For development, we can disable TLS. Never do this in production!

Edit this file /var/lib/boot2docker/profile in all of the nodes.

and change line DOCKER_TLS=auto to

DOCKER_TLS=no

Restart the docker engine in the node

sudo /etc/init.d/docker restart

You need to this in all the nodes so we can configure it in Portainer. Once configured and all docker engines restarted, we can now configure portainer. For now, let's just add node1, IP is 192.168.99.106 in this example. We can add additional endpoints later.

Screenshot-2017-11-16-20.42.05

Once logged into portainer, you can now check services running in the swarm cluster by clicking "Services" in the left menu.

Screenshot-2017-11-16-20.42.47

Let's add the other 2 nodes. Click "Endpoints" in the left menu and click +Add Endpoint. Enter node2 and node3 URLs.

Screenshot-2017-11-16-20.43.56

Screenshot-2017-11-16-20.44.51

Cool, now we have node2 and node3 added. You can now check containers running on each node.

Screenshot-2017-11-16-20.45.32

You can uncheck Show all containers so it will not display stopped containers.

Screenshot-2017-11-16-20.46.29

Swarm Visualizer is also available you can see a visual view of which services are running in each node in your swarm cluster.

Screenshot-2017-11-16-20.48.13

That's it! You can now use Portainer to manage your Docker Swarm Cluster!

Let's connect in LinkedIn, Twitter and github!

Melvin Vivas

Melvin Vivas

Father of 2 wonderful kids, loves programming, wannabee gopher, currently working at an international bank. Bloggin' about Golang, Docker, and Kubernetes.

Read More