How to Install Docker Portainer on Rocky Linux 9

Install Docker Portainer on Rocky Linux 9 with Docker CE, SELinux-aware settings, private HTTPS access, SSH tunneling, verification, and fixes.
A polished 3D Rocky Linux server rack with glowing container blocks and a secure dashboard on a midnight-blue background.

This guide shows you how to install docker portainer on rocky linux 9 and finish with a working Docker Engine plus a private Portainer CE dashboard in about ten minutes. The setup keeps Portainer off the public network, preserves its data, and gives you checks for the errors most fresh VPS installations encounter.

Prerequisites

  • A 64-bit Rocky Linux 9 VPS with at least 2 GB of RAM and 10 GB of free disk space for Docker images, containers, and Portainer data.
  • SSH access as root, or a normal account with working sudo privileges.
  • Outbound HTTPS access to Docker Hub and Docker’s package repository.
  • An SSH client on your own computer for a local tunnel. You do not need a domain for this private setup; a domain is only needed if you later publish Portainer behind a reverse proxy.
  • A VPSLake Linux VPS with root access if you need a Rocky Linux server for Docker workloads.

The commands assume a regular sudo-enabled account. If you are logged in as root, remove sudo. Rocky Linux 9 uses DNF, firewalld, and SELinux, so do not substitute Ubuntu’s APT/UFW commands.

Step 1: Confirm Rocky Linux 9 and update the host

Checking the release and CPU architecture first prevents a repository for another Enterprise Linux version from being added to the VPS.

. /etc/os-release && printf 'ID=%s\nVERSION_ID=%s\nVERSION_CODENAME=%s\n' "$ID" "$VERSION_ID" "${VERSION_CODENAME:-not-set}"
uname -m
sudo dnf -y upgrade

The first lines should identify Rocky Linux 9, and most VPSs report x86_64:

ID=rocky
VERSION_ID="9.x"
VERSION_CODENAME=not-set
x86_64

The minor release changes as Rocky publishes updates. If DNF reports DNS, mirror, or signature errors, fix those before installing Docker.

Step 2: Remove conflicting packages and add Docker’s Rocky repository

Rocky may include Podman or an older Docker package; Docker CE supplies its own container runtime and can conflict with those packages on a new host.

On a fresh VPS, remove the packages that Docker identifies as conflicts, then add Docker’s Rocky repository:

sudo dnf remove -y docker \
  docker-client \
  docker-client-latest \
  docker-common \
  docker-latest \
  docker-latest-logrotate \
  docker-logrotate \
  docker-engine \
  podman \
  runc
sudo dnf install -y dnf-plugins-core ca-certificates
sudo dnf config-manager --add-repo https://download.docker.com/linux/rocky/docker-ce.repo
sudo dnf makecache

DNF may say that some packages were not installed; that is normal. Do not remove Podman or runc from a server already running production containers until you have planned a runtime migration. Removing packages does not automatically delete Docker data in /var/lib/docker/.

Confirm that DNF can see the Rocky 9 packages before you install them:

dnf list docker-ce --showduplicates | tail -n 5

You should see docker-ce entries from Docker’s stable repository with an .el9 package suffix. The exact version changes as Docker publishes updates.

Step 3: Install, start, and test Docker Engine

Installing the Compose plugin with the Engine gives Portainer a complete Docker host and leaves docker compose available for later application stacks.

sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl enable --now docker
sudo systemctl is-active docker
sudo systemctl is-enabled docker
sudo docker version --format 'Client {{.Client.Version}} / Server {{.Server.Version}}'
sudo docker compose version

Expected output shows an active, enabled service; version numbers vary with current releases:

active
enabled
Client 29.x.y / Server 29.x.y
Docker Compose version v2.x.y

Run Docker’s disposable test image to verify the daemon, registry connection, and runtime:

sudo docker run --rm hello-world

The final output should include Hello from Docker! and Your installation appears to be working correctly. The --rm flag removes the stopped test container afterward.

Step 4: Check Rocky’s firewall and SELinux state

Portainer will bind to loopback, so you do not need a public firewall rule for its web port; checking Rocky’s security services now helps prevent an accidental SSH lockout or an unexplained container denial.

getenforce
sudo systemctl is-active firewalld
sudo firewall-cmd --state
sudo firewall-cmd --query-service=ssh

On a typical configured Rocky VPS, the results include:

Enforcing
active
running
yes

Keep SELinux enabled. Keep the existing SSH rule in place, and do not add 9443 or 8000 to firewalld for this guide: both Portainer ports remain unpublished to the public interface. If SSH is not allowed, correct that through your provider console before disconnecting your current session.

Step 5: Deploy Portainer CE with a private HTTPS listener

A named volume keeps Portainer users, settings, and environment records outside the container, while the loopback binding prevents direct internet access to the dashboard. Portainer’s official Docker installation guide uses the Docker socket and /data volume; its Linux guidance calls for --privileged when SELinux is enabled.

Create the volume and start the current long-term-support image:

sudo docker volume create portainer_data
sudo docker run -d \
  --name portainer \
  --restart=always \
  --privileged \
  --publish 127.0.0.1:9443:9443 \
  --volume /var/run/docker.sock:/var/run/docker.sock \
  --volume portainer_data:/data \
  portainer/portainer-ce:lts

Docker prints a container ID. Verify that Portainer is running and that the host-side listener is private:

sudo docker ps --filter name=portainer --format 'table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}'
NAMES      IMAGE                       STATUS       PORTS
portainer  portainer/portainer-ce:lts Up ...        127.0.0.1:9443->9443/tcp

Portainer generates a self-signed certificate for the first HTTPS connection. A browser warning is expected when you connect through the private tunnel. Port 8000 is optional for Edge Agent features and is intentionally not published here.

Step 6: Open Portainer through an SSH tunnel

The tunnel carries your browser traffic to the loopback-only listener without exposing Portainer in Rocky’s firewall.

Run this command on your local computer, not inside the VPS shell, and leave the terminal open:

ssh -N -L 9443:127.0.0.1:9443 YOUR_SSH_USER@SERVER_IP

Replace YOUR_SSH_USER with the VPS login name and SERVER_IP with its public address. The command stays open while it forwards your local port.

Open https://127.0.0.1:9443 in your browser. Accept the certificate warning only when the address is exactly 127.0.0.1, then create a strong, unique administrator password and select the local Docker environment.

New Portainer installations may request a setup token before the first administrator is created. If the page asks for one, retrieve it on the VPS:

sudo docker logs portainer 2>&1 | grep -m1 'setup_token='

If port 9443 is already occupied on your computer, change only the local side of the forward:

ssh -N -L 19443:127.0.0.1:9443 YOUR_SSH_USER@SERVER_IP

Then browse to https://127.0.0.1:19443. The VPS listener remains on loopback port 9443, so no new firewalld rule is needed.

Verify Docker and Portainer

Run these checks on the VPS to prove that Docker starts at boot, Portainer restarts automatically, SELinux-aware privilege is enabled, and HTTPS answers locally:

sudo systemctl is-active docker
sudo systemctl is-enabled docker
sudo docker inspect --format '{{.HostConfig.RestartPolicy.Name}}' portainer
sudo docker inspect --format '{{.HostConfig.Privileged}}' portainer
sudo ss -lntp | grep '127.0.0.1:9443'
curl --insecure --head --max-time 10 https://127.0.0.1:9443

Expected results include:

active
enabled
always
true
LISTEN ... 127.0.0.1:9443 ...
HTTP/1.1 200 OK

Refresh the tunneled browser page. You should see Portainer’s setup page or dashboard, and the local Docker environment should be available after setup.

Troubleshooting

No match for argument: docker-ce

DNF cannot see Docker’s Rocky repository, or its metadata is stale. Check the enabled repositories and rebuild the cache:

sudo dnf repolist --enabled | grep -i docker
sudo dnf makecache
dnf list docker-ce --showduplicates

The repository list should include Docker’s stable channel. If it is missing, repeat the Rocky repository command from Step 2 and confirm that the VPS can resolve download.docker.com over HTTPS. Do not mix in an Ubuntu or unrelated Enterprise Linux repository.

package docker-ce conflicts with podman or runc

Rocky’s default container tools are still installed. On a new VPS, repeat the removal command in Step 2 and retry the Docker installation. On an established host, do not remove the runtime blindly: identify the services using it and schedule a migration first.

Portainer logs an SELinux denial or immediately restarts

Portainer must reach the Docker socket, and SELinux can block that access without privileged container mode. Inspect the host mode, recent logs, and container setting:

getenforce
sudo docker logs --tail 100 portainer
sudo docker inspect --format '{{.HostConfig.Privileged}}' portainer

The last command should print true. If it prints false, recreate only the Portainer container with the --privileged option, loopback publish, socket mount, and portainer_data volume from Step 5. Do not disable SELinux; the named volume keeps the dashboard data.

The browser cannot connect to 127.0.0.1:9443

The tunnel may be closed, the local port may be busy, or the container may not be listening. Start the tunnel again and keep it open:

ssh -N -L 9443:127.0.0.1:9443 YOUR_SSH_USER@SERVER_IP

On the VPS, check the binding and logs:

sudo ss -lntp | grep '127.0.0.1:9443'
sudo docker ps --filter name=portainer
sudo docker logs --tail 50 portainer

Do not browse to https://SERVER_IP:9443; this setup deliberately does not publish Portainer on the public address.

Hardening

  • Keep Portainer on loopback. If you later need shared access, place it behind a reverse proxy with a trusted certificate, strong authentication, and a narrowly scoped firewalld rule.
  • Treat /var/run/docker.sock, the docker group, and the Portainer administrator account as root-equivalent access. Never expose Docker’s unauthenticated TCP API on port 2375.
  • Back up the portainer_data volume before changing the image tag or rebuilding the container.
  • Review SSH settings with VPSLake’s SSH hardening generator before relying on the tunnel for administration.

FAQ

Does Rocky Linux 9 use UFW for Docker firewall rules?

No. Rocky Linux 9 uses firewalld, managed with firewall-cmd. This guide does not open a Portainer rule because Docker publishes 9443 only on 127.0.0.1; the SSH tunnel uses your existing SSH access.

Why is --privileged needed on Rocky Linux 9?

Portainer needs to communicate with the root-run Docker daemon through the mounted Unix socket. Portainer documents privileged mode for Docker hosts that keep SELinux enabled, so the command grants the container the required access without disabling the host policy.

Do I need a domain name for Portainer?

No. The SSH tunnel makes the private dashboard available at https://127.0.0.1:9443 on your computer. Add a domain only if you later choose a public reverse-proxy deployment with trusted TLS.

What does portainer_data protect?

The volume stores Portainer’s database, users, settings, and environment configuration separately from the container. You can replace the Portainer container during a planned upgrade without removing that data.

Samrat Ghosh
Written by

Samrat Ghosh

Founder & Infrastructure Engineer

Samrat Ghosh is the founder of VPSLake, where he builds and runs the remote desktop and VPS hosting infrastructure the company is built on. He writes hands-on guides about RDP, Windows Server, VPS management and secure remote access - the practical documentation he wishes had…

Previous Article

Static IP Cost: ISP Add-On vs $4 VPS

Next Article

How to Install Docker Portainer on Ubuntu 22.04

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *

Subscribe to our Newsletter

Subscribe to our email newsletter to get the latest posts delivered right to your email.
Pure inspiration, zero spam ✨