Docker + Portainer on a VPS: install, web panel and safe access

Questions and discussions about VPS plans, Linux setup, WordPress, Nginx, NAT and VPS configuration in Bulgaria.
rychy
Site Admin
Posts: 162
Joined: Tue Oct 20, 2026 10:45 am

Docker + Portainer on a VPS: install, web panel and safe access

Post by rychy »

🇧🇬 Прочети на български

🐳 Docker + Portainer on a VPS: install, web panel and safe access

Docker runs every application in its own container: a website, a database, a bot, monitoring. They do not fight over versions, and you remove one with a single command. Portainer adds a web panel on top, so you see your containers, logs and resources in the browser. This is how we do it. The commands are for Debian/Ubuntu and AlmaLinux/Rocky.

1️⃣ Install Docker

Code: Select all

# Debian / Ubuntu — Docker's official script
curl -fsSL https://get.docker.com | sudo sh

# AlmaLinux / Rocky
sudo dnf install -y dnf-plugins-core
sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
sudo systemctl enable --now docker
Check it:

Code: Select all

sudo docker run --rm hello-world
docker compose version
💡 To run docker without sudo: sudo usermod -aG docker $USER, then log out and back in. Keep in mind that the docker group is effectively root access, so add only yourself.

2️⃣ Install Portainer

Code: Select all

sudo docker volume create portainer_data
sudo docker run -d --name portainer --restart=always \
  -p 127.0.0.1:9443:9443 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v portainer_data:/data \
  portainer/portainer-ce:lts
The 127.0.0.1: in front of the port is on purpose: the panel listens only inside the server and cannot be seen from the internet. How to reach it is the next step.
⚠️ After the first start you have about 5 minutes to create the administrator. If you miss it, Portainer locks itself for security. Then run sudo docker restart portainer and try again.

3️⃣ Open the panel through an SSH tunnel

From your own computer (Windows 10/11, macOS, Linux):

Code: Select all

ssh -L 9443:localhost:9443 -p PORT user@ssh.vpsstorages.com
While this SSH connection is open, go to https://localhost:9443 in your browser. The browser will warn about the certificate (Portainer uses its own). Accept it, that is normal. Create the administrator with a long password and choose Get Started → the local environment.
This way the panel is protected by your SSH key or password, not only by the Portainer password.

4️⃣ Your first app: a Stack with docker compose

In Portainer: Stacks → Add stack, name it web and paste:

Code: Select all

services:
  web:
    image: nginx:alpine
    ports:
      - "127.0.0.1:8080:80"
    restart: unless-stopped
Deploy the stack, and a few seconds later the container is running. Check it from the server:

Code: Select all

curl -I http://127.0.0.1:8080
From the same place you see the logs (Containers → web → Logs), open a console inside the container and watch CPU/RAM (Stats).

⚠️ Docker bypasses the firewall

This is the most common surprise. A port published as -p 8080:80 is opened by Docker directly in iptables, around ufw/firewalld. So:
  • publish ports as 127.0.0.1:PORT:PORT when the service is only for you or for a reverse proxy on the same server;
  • never publish databases (MySQL, PostgreSQL, Redis) to the outside. Containers in one stack see each other by name, without any port;
  • check what is really listening: sudo ss -tlnp.

🔄 Updating Portainer

The data lives in the portainer_data volume, so you can replace the container safely:

Code: Select all

sudo docker pull portainer/portainer-ce:lts
sudo docker stop portainer && sudo docker rm portainer
sudo docker run -d --name portainer --restart=always \
  -p 127.0.0.1:9443:9443 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v portainer_data:/data \
  portainer/portainer-ce:lts
Clean up old images now and then: sudo docker image prune.

🛡️ With us it is one tick

When you order a Linux VPS with the Docker or Developer environment, you can pick the free Portainer add-on. The server comes with Docker and Portainer CE, HTTPS only, and the panel opens directly at <name>-panel.vpsstorages.com, no tunnel needed. The login details arrive in the order email.

Questions, or your own stacks? Post them here in the topic 👇

Return to “VPS questions and setup”