Portainer: How to make your work with Docker easier

Today we are going to see a little Portainer, which is a visual tool that will allow us to access more easily to the information that Docker offers us. For those who already have a wide domain of Docker, maybe it isn’t necessary. But if you still don’t have a complete domain, a good memory for the commands or you simply like to use a graphic interface, this is your program.

To start we will see how we can start it. As it’s a tool for the management of Docker, we will see two ways to launch through it. The first is to start it as a standalone container, through the following command:

docker run -d -p 9000:9000 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v portainer_data:/data portainer/portainer

About this command we can comment on several important things:

  • The port 9000 will be the one that allows us to access the Portainer interface.
  • The volume that allows us to link the socket of the Docker engine. In case we use Windows, this path will be different.
  • And finally, we indicate a folder where we want to persist the information.

The only way to access it is through the following URL http://localhost:9000. The first time we enter, we will be asked for the administrator’s password.

Now we have already seen how to start in a standalone way. But I think it is much more useful if we see how to start it inside a docker-compose.

To do this we must modify a docker-compose.yml file. And add the following code:

As we can see it is quite similar, but I describe it for those who do not know so much docker-compose.

  • We indicate the image and version that we are going to use.
  • The name of the container and the machine inside it.
  • We indicate the IP in the internal network that we have created for the docker-compose.
  • We indicate the mapping of ports from the container to the outside. In this case in addition to 9000, we expose 8000. This enables the endpoint for the edge agent. More information here.
  • We indicate that when starting the container we can set the administrator’s password.
  • We indicate the volumes as we did in the case of the standalone.
    The most complex thing can be the password. It must have at least 8 characters and be encoded in Bcrypt. Here you have a website that allows you to generate them. However, the $ symbols must be escaped with another $ symbol to avoid errors when starting, such as Invalid interpolation format for “command” option in service “portainer”.

Now when you start, you will see a screen like this:

We can now access with our password and see the different options it provides. But the first time we access we must indicate which docker instance we want to connect to. We can choose a local, remote, edge, or from Azure. In our example, we will obviously choose the local one.

Once inside, we will go directly to the option in the side menu Home. And we can see a very intuitive menu of what we can do.

We can access the containers, images, networks, or volumes that we have created. All of this is also accessible through the command line of the docker itself. But as I said at the beginning it will be very useful if we are not very skilled with the command line or just prefer the UI. But let’s look at several options with a little more depth.

From the Containers tab, we can see the different containers displayed, access to their logs, inspect them, or control their use and statistics.

As you can see, you can stop, delete, or restart any container with just a couple of clicks. By clicking on them we will also access more information about the container and we will be able to continue doing these quick actions.

We can also easily access the container and execute commands within it. Through the quick action Exec Console.

From the side menu we can access all Docker images. As same as the containers, we can access more information by clicking on them or even deleting them. We can also import and export other images.

Another strong point is that the lists can be ordered by all their fields and also allow us to indicate the number of elements to be displayed.

And the same can be done with the internal networks.

And the same with the volumes, also. Personally, I find this section very useful and interesting. Because it will allow us to easily clean up old volumes of which we may not be aware. Besides, with the order of the lists, we will be able to solve it quickly.

Another and interesting section are templates. Which will allow you to display with a single click any of the containers that are displayed in the list.

Otherwise, we will also have configuration options at the bottom of the side menu, not associated with the Docker engine.