You do need docker to run portainer. If you don’t have that already, I’d advice you to look at docker.

install portainer

portainer documentation

I followed this video:

sudo apt update
sudo apt dist-upgrade
sudo docker run -d -p 9443:9443 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest

open the webbrowser and goto <ipAdress>:9443 create your administrator account (and save it)

updating portainer

Important

Starting from Portainer CE 2.9 and BE 2.10, HTTPS is enabled by default on port 9443. These instructions will configure Portainer to use 9443 for HTTPS and do not expose 9000 for HTTP. If you need to retain HTTP access, you can add:

-p 9000:9000

to the sudo docker run -d -p 9443:9443 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest command.

You can also choose to completely disable HTTP after the update. Before you make Portainer HTTPS only, make sure you have all your Agents and Edge Agents already communicating with Portainer using HTTPS.

Warning

Before beginning any update, Portainer devs highly recommend taking a backup of your current Portainer configuration.

Even though portainer is a docker container itself, so everything should go without errors, and your other containers should keep running whilst migrating. The keyword is Should, since you never know if something unlikely will occur.

That being said, I used contabo’s snapshot to back it up, and not portainers backup method.

based on this article.

Info

I, the auther of this article, assume that u use the community edition of portainer. If you don’t, visit the url above to find the correct counterparts of step 4 and 5.

Go back to the console (if you left it) and run:

sudo docker stop portainer
sudo docker rm portainer
sudo docker pull portainer/portainer-ce:latest
sudo docker run -d -p 9443:9443 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest

doing this once in a while is a good idea (portainer notifies you on updates). Doing the following commands are also smart to do when you are at it:

sudo apt update
sudo apt upgrade

Adding a vps environment

In this section I am going to connect my VPS with portainer to my local portainer.

1.Run portainer agent on your VPS

open your VPS and run the following:

sudo docker run -d \
  --name portainer_agent \
  --restart=always \
  -p 9001:9001 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  portainer/agent

2.Choose how to connect

Option 1: Connect Directly via Public IP

Security issue

This method means that everyone with your VPS IP can connect to your portainer this way.

In your local Portainer, go to:

  • Add Environment
  • Select Docker Standalone
  • Select Agent

Then put the environment address to: <vps_ip>:9001 and connect.

This avoids exposing port 9001 publicly and tunnels traffic securely over SSH.