Portainer Deployment on Docker Swarm

In previous blog posts I have discussed the concept of Docker and what constitutes a container.  For this blog post we will cover another subsection of the Docker engine, Docker Swarm. What is Docker Swarm?  Docker Swarm is a clustering and scheduling tool for Docker containers. With Swarm, administrators and developers can establish and manage a cluster of Docker nodes as a single virtual system.  Additionally, Swarm can handle load balancing and other networking structure automatically to help remove the amount of configuration needed to spin up a multi-container image.

Swarm mode also exists natively for Docker Engine, the layer between the OS and container images. Swarm mode integrates the orchestration capabilities of Docker Swarm into Docker Engine 1.12 and newer releases.  Swarm engages clustering capabilities for management.  Clustering is an important feature for container technology, because it creates a group of systems that can provide redundancy, enabling Docker Swarm failover if one or more nodes experience an outage. A Docker Swarm cluster also provides administrators and developers with the ability to add or subtract container iterations as computing demands change.

An administrator can control all the nodes of the Swarm through a swarm manager, which orchestrates and schedules containers.  The swarm manager allows a user to create a primary manager instance and multiple replica instances in case the primary instance fails.  

The official documentation of Docker Swarm is at the following link.  

Speaking of ease of management. Portainer is an open-source lightweight management UI which allows administrators and developers to easily manage docker hosts or swarm clusters.  

Setting up Portainer inside of the Docker Swarm is very simple.  In fact two commands run on the Swarm management node is all that it takes to setup Portainer.  

$ curl -L https://portainer.io/download/portainer-agent-stack.yml -o portainer-agent-stack.yml
$ docker stack deploy --compose-file=portainer-agent-stack.yml portainer

In the commands above simply pulling down the Portainer yml file and the deploying using the already installed Docker engine is all that it takes to deploy Portainer.  The administrative interface is now accessible at http://docker.ip:3000

Portainer will ask the administrator to setup the admin password on the first time logging in.  Once that is setup, the webserver will direct the user to the dashboard. Immediately you will see on the dashboard that Portainer is already showing the running containers.  As you can see from the screenshot below that Portainer has already deployed the portainer agents to the individual nodes of the Docker Swarm.  

`

Additionally, Portainer will give you an overview of the nodes that are connected and various amounts of information about the device.  

Cluster overview will show the total amount of resources of the Docker Swarm from all connected nodes.  In the screenshot below you can see the three Debian VMs that were spun up for this demonstration equal roughly 3 GB of memory total.  1 GB on each individual VM.  

The cluster visualizer will give a visual view of where each container is deployed and the status of the container.  For example, in the screenshot below it shows which nodes the Portainer agents are installed on.  

Another advantage of Portainer is the use of App Templates.  These templates allow for nearly flawless setup to be deployed within seconds, and minimum clicks required.  As you can see in the screenshot below by simply using the WordPress app template I was able to deploy the appropriate containers across the three nodes connected.  

As I continue to explore the world of Docker Swarm and Portainer I hope to come back to this blog post and demonstrate how load balancing works, and more intricate configurations that can be used.  

Until next time, keep on learning!