How to install Portainer on Linux OS (Ubuntu, Debian, CentOS, Raspbian)
Overview:
Portainer is docker web GUI application in where you can manage all your docker containers, Images and Volumes. It offers more features than just showing docker containers but you can even manage other docker nodes in one Portainer application.
This guide will show you how easy is to install Portainer on any linux machines but before that you need to keep in mind that it needs some preparation before installing it.
There are two method is to install Portainer but this guide will show you the easiest one.
Installation.
The easiest method to install Portainer is of course is docker. To manage Docker, you need to deploy a docker container that contains Portainer binary and it access host docker process file to get all information what are docker containers with volumes are running.
Check out our guide on how to install Docker on Linux so you can install Portainer.
Now, Here we go, To Install Portainer here is this one line command that simply pulls up the Portainer image.
sudo docker run --name portainer --restart=unless-stopped -d -p 8000:8000 -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer
In this line of command, We specified docker name "portainer" and port in which Portainer Docker can be accessible to the public network. Which in this case is port "9000"
- "-v portainer_data" is host location where on the Docker Host the Portainer data.
- "-v /var/run/docker.sock" is Docker process where portainer can access all information and control docker applications.
- "portainer/portainer" is the official docker image which will get pull from official Docker repository.
Acess Portainer GUI
Now, Go to the browser and put Docker Host Server IP in there like this:
http://[public-ip-address]:9000
Replace your public ip address in above field and if you are running docker in your private machine then put your private IP like : 192.168.0.10:9000,192.168.1.10:9000 and so on..
Portainer Docker Process
To check if portainer is running on your host machine simply run below command,
sudo docker ps
Command Output:
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9a83bdecfc56 portainer/portainer "/portainer" 2 hours ago Up 2 hours 0.0.0.0:8000-8000/tcp, 0.0.0.0:9000->9000/tcp portainer
Above output it shows that it exposes application to port 8000 and port 9000 but we use 9000 to access Portainer GUI.
Update Portainer
If you want to update Docker of Portainer then simple run these following commands,
sudo docker pull portainer/portainer
Above command will pull the latest image from official docker repository but it will not update the current running Portainer Docker so we will stop the running container so it will use updated image.
sudo docker stop portainer
Here we have stopped our Portainer container and if you seem to notice we don't have to use docker id to stop portainer container but we used "portainer" name and this happened because we gave our docker container a name called "portainer" so using a name for container is makes easy to manage like stop and run the container.
Now, Delete old Portainer image to replace updated one.
sudo docker rm portainer
Above command will delete only image but not the volume where we are keeping our Portainer data.
Re-run the docker portainer command to launch portainer with updated image at same volume and exposed ports we have given before.
sudo docker run --name portainer --restart=unless-stopped -d -p 8000:8000 -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer
Check again for docker process and if it's running then we are good to know. Hope this guide helped you.