Managing Docker with an UI with Portainer
When you run many Docker images on hosts, the management of these containers can become difficult because you use command lines. There are many solutions to manage Docker containers and images with an user interface. In this story, I introduce one, Portainer. It’s very easy to install and very convenient.
Portainer is a web interface for managing Docker hosts, and clusters in swarm mode. This open source (https://portainer.io) is written in Go. In this article, I will show how to set up a Portainer instance, in two modes:
- by launching in Swarm mode,
- by using Docker
Launch Portainer in Swarm mode
Let’s initialize Swarm:
docker swarm init
The output is:
Swarm initialized: current node (me24tqmi0qzery2qeyxtzmw2k) is now a manager.To add a worker to this swarm, run the following command: docker swarm join --token SWMTKN-1-660w00j7bq2b0bd78icmzpu5kqq94d5a8mcxsckxrn7s9sne8c-blsp2jfypcm8xf53txbt0li2c 192.168.0.111:2377To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
Let’s add this ECS instance as a manager to the swarm:
docker swarm join-token manager
The output is:
To add a manager to this swarm, run the following command: docker swarm join --token SWMTKN-1-660w00j7bq2b0bd78icmzpu5kqq94d5a8mcxsckxrn7s9sne8c-5osr0cofqkyk3obisqz8d1loj 192.168.0.111:2377
Now, let’s create the service:
docker service create --name portainer --publish 9000:9000 --constraint 'node.role == manager' --mount type=bind,src=//var/run/docker.sock,dst=/var/run/docker.sock portainer/portainer -H unix:///var/run/docker.sock
In Swarm mode, the list of the nodes is displayed.
In a web browser, let’s go to Portainer at http://8.208.90.125:9000/
.
At the first access, you must choose a password for the administrator:

Select the local mode (Local — Manage the local Docker environment):

Welcome in Portainer:

When you click on « local », the following screen is displayed:

Portainer allows you to create containers and services.
The Services view displays the running services.
The Volumes and Containers view only shows the resources on the node where the Portainer is running.
Launch Portainer with Docker Compose
Create a directory to store data of the Portainer instance:
mkdir /opt/portainer
Let’s launch Portainer :
cat << EOF > docker-compose.yml
version: '3'
services:
portainer:
image: portainer/portainer
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /opt/portainer:/data
ports:
- 9000:9000
restart: always
EOF
Create the containers:
docker-compose up -d
Welcome in Portainer:

When you click on « local », the following screen is displayed:

So, now, you can still use command lines to manage Docker for specific actions but with Portainer you can get an overview of the containers on the hosts.
More articles on my blog http://www.DevOpsTestLab.com.
My DevOpsTestLab Youtube channel.
My LinkedIn profile: https://fr.linkedin.com/in/brunodelb