×
Community Blog Managing Docker with an UI with Portainer

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.

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

Preparation of the environment

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:

portainer_1

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: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:

portainer_2

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

portainer_3

Welcome in Portainer:

portainer_4

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

portainer_5

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:

portainer_6

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

portainer_7

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

0 0 0
Share on

Bruno Delb

4 posts | 1 followers

You may also like

Comments

Bruno Delb

4 posts | 1 followers

Related Products

  • VPN Gateway

    VPN Gateway is an Internet-based service that establishes a connection between a VPC and your on-premise data center.

    Learn More