portainer
Picture of Rens Hoskens

Rens Hoskens

Full stack Java developer with great interest in everything IT related.

How to install Portainer, a GUI for docker!

Facebook
Twitter
LinkedIn
Telegram

We will install Portainer as a docker container. Since Portainer writes data to the disk and we don’t want that data to disappear when the container is restarted, we need to create a volume. To do so, execute the following command:

docker volume create portainer_data

It will output the name of the volume, which is portainer_data.

Next, we will create the Portainer container:

docker run -d -p 9000:9000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce

This command may look complex, but when you look at the separate parts, it is not so difficult. First we tell docker to run in the background and print the container id, we do that with docker run -d.

Next we want docker to expose a container port (9000 in this case) to a local machine port (also 9000): -p 9000:9000.

With --name portainer we give the container the name “portainer”, and with --restart always we tell docker that this container should start when it has been stopped. This also makes sure that when the docker host is restarted, this container is started as well.

Then we need to mount 2 different “directories” to the container. Portainer needs to be able to start other docker containers and we do so by mapping the docker socket to the docker socket in the container: -v /var/run/docker.sock:/var/run/docker.sock. The other directory is the volume we created earlier: -v portainer_data:/data.

Finally we tell docker which image it needs to use to create the container with: portainer/portainer-ce.

Wait a few moments and let the container start up. When that is done, you can surf to http://<ip-address-of-your-machine>:9000 and start the introduction of Portainer!

portainer init screen

Facebook
Twitter
LinkedIn
Telegram

More to explore

Rens Hoskens

K3s: Kubernetes made easy

Kubernetes is used in a lot of companies. But what if you have no experience with it? K3s by Rancher is the solution! Here I show you how to install and configure it.

Read More »