Use Portainer.io to manage a Docker Swarm installation on Azure

Since the shutdown of Docker Cloud, I have been looking for a replacement that is as simple and powerful as Docker Cloud. So now I am just trying out different approaches on how to make my own version of Docker Cloud. This is one of the steps towards the ultimate goal that is to create something that is 100% declarative, both for Infrastructure and the Containers running on this Infrastructure.

First, to test Portainer.io we need some infrastructure, but this is covered in the article: http://geircode.no/setting-docker-community-edition-azure/

Following the results of this article, we now have a working Docker Swarm on Azure.

Goal

Use Portainer.io to manage a Docker Swarm installation on Azure

What is Portainer.io?

“Portainer.io is an open-source lightweight management UI which allows you to easily manage your Docker hosts or Swarm clusters”

The plan is use this solution to manage the Containers visually from the web. Docker Swarm does not have any default ‘gui’ that makes it easy to login to the container shell, deploy stacks, monitor cpu and memory. Hopefully Portainer.io can bridge this gap.

Get started

To avoid bloating my own developer laptop, I create my own workspace in a Container and work from there and keep the files on Bitbucket. That way I can move my workspace around on different computers without caring about snowflakes. The template workspace setup used is shared here: https://bitbucket.org/geircode/setting_up_docker_community_edition_template

Starting the workspace container

Let’s find the commands and certificates used in the previous article.

You may need to copy the certificate files from the shared volume from /app/ubuntu to /ubuntu. This is because shared volume in Docker for Windows forces all files to get a different file mode which is not possible to change during the volume sharing.

sh 005_prepare_ubuntu_keypair.sh

# Login

# ssh -i <path to public certificate> -p 50000 docker@<docker swarm public IP>

ssh -i /ubuntu/geircode_19f93204_rsa -p 50000 docker@13.80.106.142

After logging into the Docker Swarm manager, we are ready to install Portainer.

Starting Portainer

Following the docs: https://portainer.readthedocs.io/en/stable/deployment.html#inside-a-swarm-cluster

Login to the Manager node and start Portainer using these commands:

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

Navigate to the Public IP of the “externalLoadBalancer” in Azure:

Even the “Load balancing rules” is automatically configured:

Navigate to IP and port:

Oh my…That was easy, but is it working?

Yep, it is working:)

Deploying locally on Docker for Windows

First tick this option in Docker For Windows:

Open a CMD and execute:

>> “docker swarm init”

Get the script from https://bitbucket.org/geircode/setting_up_docker_community_edition_template/src/master/portainer/

Execute, and navigate to http://localhost:9000/

And it just works out of the box. That’s indeed pretty fantastic.

Goal reached and then some.

Leave a Reply

Your email address will not be published. Required fields are marked *