This guide shows you how to install Docker Portainer on Ubuntu 22.04 and finish with a persistent Portainer CE dashboard in about ten minutes. The dashboard stays off the public network and is opened securely through an SSH tunnel.
Prerequisites
- A 64-bit Ubuntu 22.04 LTS (Jammy) VPS with at least 2 GB of RAM and 10 GB of free disk space for Docker images and Portainer data.
- Root access or a normal SSH account with
sudoprivileges. - Outbound HTTPS access to Docker’s package repository and Docker Hub.
- An SSH client on your own computer. You do not need a domain because this guide uses a private tunnel.
- A VPSLake Linux VPS if you need a root-access Ubuntu server for Docker workloads.
The commands assume a sudo-enabled account. If you are logged in as root, remove sudo from each command. Run the tunnel command later on your own computer, not inside the VPS shell.
Step 1: Confirm Ubuntu 22.04 and update APT
Checking the release first prevents Jammy from receiving packages intended for another Ubuntu version.
. /etc/os-release
printf 'ID=%s\nVERSION_ID=%s\nVERSION_CODENAME=%s\n' "$ID" "$VERSION_ID" "$VERSION_CODENAME"
sudo apt-get update
sudo apt-get upgrade -y
Expected output identifies Ubuntu 22.04 and the jammy codename; the package counts will vary:
ID=ubuntu
VERSION_ID="22.04"
VERSION_CODENAME=jammy
If the release is not Ubuntu 22.04, stop and use the Docker repository instructions for the release actually installed on the VPS.
Step 2: Add Docker’s official Jammy repository
Ubuntu’s docker.io package is maintained separately from Docker Engine. Docker’s official Ubuntu installation guide supplies the Engine, containerd, Buildx, and Compose plugin as one compatible package set.
On a fresh VPS, remove unofficial packages if they are present. This does not delete /var/lib/docker, but do not remove an existing runtime on a production host until its containers are backed up:
dpkg-query -W -f='${binary:Package} ${db:Status-Abbrev}\n' docker.io docker-compose docker-compose-v2 docker-doc docker-buildx podman-docker containerd runc 2>/dev/null | awk '$2 ~ /^ii/ {print $1}' | xargs -r sudo apt-get remove -y
Install the repository prerequisites, store Docker’s signing key in APT’s keyring directory, and register Jammy explicitly:
sudo apt-get install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
sudo tee /etc/apt/sources.list.d/docker.sources > /dev/null <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: jammy
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF
sudo apt-get update
Confirm that APT has a candidate from Docker’s repository before installing the daemon:
apt-cache policy docker-ce | sed -n '1,8p'
The output should show a Candidate version and a repository line containing download.docker.com.
Step 3: Install and test Docker Engine
Installing the Compose plugin at the same time gives Portainer a complete Docker host for future application stacks.
sudo apt-get 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
The service should be active and enabled, with version numbers that change as Docker releases updates:
active
enabled
Client x.y.z / Server x.y.z
Docker Compose version v2.x.y
Run Docker’s disposable test image. It checks daemon access, registry connectivity, and the container runtime, then removes the stopped test container:
sudo docker run --rm hello-world
The final lines should include Hello from Docker! and Your installation appears to be working correctly.
Step 4: Deploy Portainer CE on a private listener
The named volume preserves Portainer’s users and settings, while the loopback binding prevents the HTTPS dashboard from accepting direct internet connections.
Create the data volume and start the current long-term-support image:
sudo docker volume create portainer_data
sudo docker run -d \
--name portainer \
--restart=always \
--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. Check that Portainer is running and that its host-side port is loopback-only:
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’s Docker installation documentation uses 9443 for its HTTPS interface. Port 8000 is only needed for Edge Agent tunnel features, so it is deliberately not published here. Because the service binds to 127.0.0.1, do not add a public UFW rule for 9443; Docker also warns that publicly published container ports can bypass normal UFW expectations.
Step 5: Open Portainer with an SSH tunnel
The SSH forward carries your browser traffic to the private VPS listener without creating an internet-facing management port.
Run this on your own computer and leave the terminal open:
ssh -N -L 9443:127.0.0.1:9443 YOUR_SSH_USER@SERVER_IP
Replace YOUR_SSH_USER with your VPS login name and SERVER_IP with its public address. Open https://127.0.0.1:9443 in your browser. Portainer creates a self-signed certificate initially, so a certificate warning is expected when the address is exactly 127.0.0.1.
Create the first administrator immediately with a unique password, then select the automatically detected local Docker environment. The first account controls the Portainer instance, so do not reuse your VPS or email password.
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 Portainer listener on the VPS remains 9443.
Verify Docker and Portainer
Run these checks on the VPS to prove that Docker starts at boot, Portainer has a restart policy, the dashboard is private, and its HTTPS endpoint answers locally:
sudo systemctl is-active docker
sudo systemctl is-enabled docker
sudo docker inspect --format '{{.HostConfig.RestartPolicy.Name}}' portainer
sudo ss -lntp | grep '127.0.0.1:9443'
curl --insecure --silent --show-error --output /dev/null --write-out '%{http_code}\n' https://127.0.0.1:9443
Expected results include:
active
enabled
always
LISTEN ... 127.0.0.1:9443 ...
200
Refresh the tunneled browser page. You should see Portainer’s login page or dashboard, and the local Docker environment should be available after the setup wizard completes.
Troubleshooting
docker-ce has no installation candidate
APT cannot see the Docker repository, usually because the source file has the wrong suite or the key download failed. Check the source and refresh its metadata:
cat /etc/apt/sources.list.d/docker.sources
sudo apt-get update
apt-cache policy docker-ce
The source should say Suites: jammy and URIs: https://download.docker.com/linux/ubuntu. Do not replace it with a Debian URL or a different Ubuntu codename.
permission denied while trying to connect to the Docker daemon socket
The Docker socket is root-owned, which is why every command in this guide uses sudo. Keep using sudo, or grant one trusted login access and reconnect before testing:
sudo usermod -aG docker YOUR_SSH_USER
The docker group grants root-equivalent control of the host. Use it only for an account that should be allowed to administer the entire VPS.
bind: address already in use
Another process already owns port 9443 on the VPS, or your computer already has a local listener. Locate the VPS-side process first:
sudo ss -lntp | grep ':9443'
If the conflict is on your computer, use the 19443 local tunnel shown in Step 5. If the VPS port belongs to another service, stop or reconfigure that service before recreating Portainer with a different loopback port.
Your Portainer instance has timed out for security purposes
Portainer closes a new, unconfigured instance when the first administrator is not created promptly. Restart it, reconnect the SSH tunnel, and complete the setup page:
sudo docker restart portainer
Keep the portainer_data volume attached. Removing it would erase the saved Portainer configuration and users.
Hardening
- Keep Portainer on loopback. If you later make it public, use a reverse proxy with a trusted certificate, a narrowly scoped firewall rule, and strong authentication.
- Treat the Docker socket and Portainer administrator account as root-level access. Limit SSH to trusted users and back up
portainer_databefore upgrades. - Use VPSLake’s SSH hardening generator to review SSH settings before relying on the tunnel for administration.
FAQ
Can Portainer manage containers on another VPS?
Yes. Portainer can add remote Docker environments, but that requires a deliberate agent or secured API connection between hosts. This tutorial configures only the local Docker socket, which avoids exposing a Docker API over the network.
Is port 8000 required for a normal Portainer installation?
No. Portainer Server uses HTTPS on 9443 for its web interface. Port 8000 supports optional Edge Agent tunnel features and is unnecessary when Portainer manages Docker on the same VPS.
Can I open Portainer directly at https://SERVER_IP:9443?
Not with this setup. The service listens only on the VPS loopback address, so direct public access is intentionally refused; use the SSH tunnel and visit https://127.0.0.1:9443 locally.
How do I update Portainer without losing its settings?
Keep the portainer_data volume, pull the newer portainer/portainer-ce:lts image, and recreate only the container during a maintenance window. Docker containers and images managed by Portainer remain separate from Portainer’s own database.