You do need docker to run portainer. If you don’t have that already, I’d advice you to look at docker.
install portainer
Installing docker
If you don’t have docker yet, run
apt install docker.io
I followed this video:
sudo apt update
to look for updatessudo apt dist-upgrade
to update packages or the system, idk- you might have to install docker if you don’t have it already
sudo docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce
- open the webbrowser and goto
<ipAdress>:9000
- create your administrator account (and save it)
Updating Portainer on install
Now weirdly enough this doesn’t take the latest version of portainer. So I recommend using the update steps below.
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 your 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)
- run
sudo docker stop portainer
- run
sudo docker rm portainer
- run
sudo docker pull portainer/portainer-ce:latest
- run
sudo docker run -d -p 8000:8000 -p 9443:9443 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
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.
Option 2: Secure SSH Tunnel (Recommended)
This avoids exposing port 9001 publicly and tunnels traffic securely over SSH.