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:
Let’s prepare the environment.
Create an ECS instance with a public IP address (in my example : 8.208.90.125) and a security group allowing the 9000 port:
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:2377
To 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.
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.
Bruno Delb
Test the system security as you Test as Code the application security
8 posts | 1 followers
FollowAlibaba Cloud Indonesia - November 5, 2021
Alibaba Cloud Storage - June 19, 2019
Alibaba Cloud Indonesia - October 25, 2022
Alibaba Clouder - January 24, 2019
Alibaba Clouder - June 11, 2020
Bruno Delb - September 22, 2020
8 posts | 1 followers
FollowAlibaba Cloud Container Service for Kubernetes is a fully managed cloud container management service that supports native Kubernetes and integrates with other Alibaba Cloud products.
Learn MoreMore Posts by Bruno Delb