Install Docker Portainer on Ubuntu 24.04 and finish with a working Docker Engine plus a persistent Portainer CE dashboard in about ten minutes. The dashboard stays on the VPS itself, while an SSH tunnel lets you open it securely from your workstation. You will use Ubuntu’s Noble package metadata and Docker’s official repository, not the older apt-key method.
Prerequisites
- A 64-bit Ubuntu 24.04 LTS VPS with at least 2 GB of RAM and 10 GB of free disk space for images, containers, and Portainer data.
- SSH access as
root, or a regular account with workingsudoprivileges. - Outbound HTTPS access to
download.docker.comand Docker Hub. - An SSH client on your workstation and a browser. This private setup does not need a domain name; you will browse to
127.0.0.1through a tunnel. - A VPSLake Linux VPS with root access if you need a fresh Ubuntu server for Docker workloads.
The commands below use sudo. If you are logged in as root, remove sudo from the commands. Keep your existing SSH firewall rule in place; this guide does not publish Portainer’s management port to the internet.
Step 1: Confirm Ubuntu 24.04 and update the VPS
Checking the release first prevents APT from receiving a repository for the wrong Ubuntu codename.
. /etc/os-release && printf 'ID=%s\nVERSION_ID=%s\nVERSION_CODENAME=%s\n' "$ID" "$VERSION_ID" "$VERSION_CODENAME"
uname -m
sudo apt-get update
sudo apt-get full-upgrade -y
The release should be Noble and the architecture should normally be x86_64:
ID=ubuntu
VERSION_ID="24.04"
VERSION_CODENAME=noble
x86_64
If the first command identifies another release, stop and use instructions for that release. Do not force Noble packages onto a different Ubuntu version.
Step 2: Remove packages that can conflict with Docker Engine
Ubuntu may already contain distribution packages with names that overlap Docker’s official packages, so remove only installed conflicts before adding the new repository.
dpkg-query -W -f='${db:Status-Abbrev} ${binary:Package}\n' docker.io docker-compose docker-compose-v2 docker-doc docker-buildx podman-docker containerd runc 2>/dev/null | awk '$1 ~ /^ii/ {print $2}' | xargs -r sudo apt-get remove -y
No output means none of those packages were present. Removing packages this way does not erase images, containers, or volumes stored under /var/lib/docker/; on an existing host, still identify important workloads before changing their runtime.
Step 3: Add Docker’s official Ubuntu repository
The repository supplies Docker Engine, the CLI, containerd, Buildx, and the Compose plugin as a compatible set. Docker’s Ubuntu installation guide now uses a per-repository keyring and a deb822 source file, which avoids the deprecated global apt-key store.
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: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF
sudo apt-get update
Check that APT can see a candidate for Ubuntu 24.04 before installing anything:
apt-cache policy docker-ce | sed -n '1,6p'
docker-ce:
Installed: (none)
Candidate: 5:...~ubuntu.24.04~noble
The exact version changes as Docker publishes updates. The important detail is that the candidate comes from Docker’s repository and ends in the Noble release.
Step 4: Install and test Docker Engine
Installing the Compose plugin at the same time leaves you ready to deploy application stacks from Portainer later.
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
Expected output has an active, enabled service; version values 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 container runtime:
sudo docker run --rm hello-world
Near the end of the response, Hello from Docker! and Your installation appears to be working correctly. confirm that Docker ran a container successfully.
Step 5: Check UFW and keep Portainer private
Docker-published ports can interact with UFW’s packet filtering in surprising ways, so the safest single-server layout is to publish Portainer only on the VPS loopback address.
sudo ufw status verbose
sudo ss -lnt | sed -n '1,12p'
If UFW is active, its output should retain an allow rule for your SSH service. Do not add a public rule for 9443: the Portainer command in the next step binds that port to 127.0.0.1, and the SSH tunnel will carry browser traffic to it.
Step 6: Deploy Portainer CE with persistent HTTPS data
The named volume keeps Portainer’s users, settings, and environment records when the container is replaced. Portainer’s official Docker installation guide uses the Docker socket and HTTPS listener shown here; port 8000 is omitted because it is only needed for Edge Agent tunnel features.
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. Confirm 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 creates a self-signed certificate for its first HTTPS connection. That warning is expected when you connect through the local tunnel; do not publish the container on 0.0.0.0 just to avoid it.
Step 7: Open Portainer through an SSH tunnel
The tunnel makes the VPS-only listener available at a local address without adding another inbound firewall rule.
Run this on your workstation, not in the VPS shell, and keep the terminal open:
ssh -N -L 9443:127.0.0.1:9443 YOUR_SSH_USER@SERVER_IP
Replace YOUR_SSH_USER with the SSH account on the VPS and SERVER_IP with its public address. Open https://127.0.0.1:9443 in your browser, accept the certificate warning only for that local address, and create a unique administrator password of at least 12 characters. Portainer’s first account is an administrator, so do not reuse an SSH or billing password.
If port 9443 is already used on your workstation, change only the local side:
ssh -N -L 19443:127.0.0.1:9443 YOUR_SSH_USER@SERVER_IP
Then visit https://127.0.0.1:19443. The VPS still listens privately on 9443.
Verify Docker and Portainer
Run these checks on the VPS to prove that Docker starts at boot, Portainer has an automatic restart policy, the listener is loopback-only, and HTTPS 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
active
enabled
always
LISTEN ... 127.0.0.1:9443 ...
200
Refresh the tunneled browser tab. You should see Portainer’s setup page or dashboard, and the local Docker environment should be available after the setup wizard completes.
Troubleshooting
E: Package 'docker-ce' has no installation candidate
APT is usually reading the wrong suite, or the source file was not created successfully. Check the release and repository metadata, then rerun Step 3 rather than switching to an Ubuntu mirror for another release:
. /etc/os-release && printf 'ID=%s\nVERSION_CODENAME=%s\n' "$ID" "$VERSION_CODENAME"
grep -E '^(Types|URIs|Suites|Components|Architectures|Signed-By):' /etc/apt/sources.list.d/docker.sources
sudo apt-get update
apt-cache policy docker-ce
The suite should be noble, and the policy output should show Docker’s repository. A different OS release needs its own repository instructions.
permission denied while trying to connect to the Docker daemon socket
The Unix socket is root-owned, which is why the guide uses sudo docker. Continue with sudo, or grant access to one trusted administrator and reconnect before testing:
sudo usermod -aG docker YOUR_SSH_USER
The docker group provides root-equivalent control over the host. Log out completely and reconnect before running docker info without sudo; do not add application users to this group.
bind: address already in use for port 9443
Another process already owns the requested host port. Find it before changing the mapping:
sudo ss -lntp | grep ':9443'
sudo docker ps --format 'table {{.Names}}\t{{.Ports}}'
If the port belongs to an unrelated service, keep it and recreate Portainer with --publish 127.0.0.1:19443:9443; then tunnel local port 19443 to the same VPS port and browse to https://127.0.0.1:19443.
https://SERVER_IP:9443 does not load or Portainer timed out
The public address is not the URL used by this setup. Start the SSH tunnel again and use https://127.0.0.1:9443; if initial setup was not completed promptly, restart the container and finish the wizard:
sudo docker restart portainer
If the container keeps restarting, inspect the last messages with sudo docker logs --tail 80 portainer. Keep portainer_data mounted so a restart does not discard the dashboard configuration.
Hardening
- Keep port 9443 on loopback. If you later need team access, use a domain, a reverse proxy with a trusted certificate, strong authentication, and a narrowly scoped UFW policy.
- Treat
/var/run/docker.sock, membership in thedockergroup, and the Portainer administrator account as root-equivalent access. - Back up the
portainer_datavolume before changing the image tag or rebuilding the container. - For a deliberate SSH and UFW baseline, review VPSLake’s UFW firewall generator and keep SSH access allowed before applying changes.
FAQ
Why use Docker’s repository instead of Ubuntu’s docker.io package?
Ubuntu’s package and Docker’s official Engine packages are maintained through different release channels. The official repository provides Docker Engine together with the matching containerd, Buildx, and Compose plugin packages used in this guide.
Do I need a domain name for Portainer on Ubuntu 24.04?
No. The SSH tunnel exposes the private HTTPS service only on your workstation, so https://127.0.0.1:9443 is sufficient. A domain becomes useful when you intentionally publish Portainer behind a reverse proxy with a trusted certificate.
What is Portainer port 8000 used for?
Port 8000 is an optional tunnel for Portainer Edge Agent features. A Portainer Server managing Docker on the same VPS through /var/run/docker.sock can leave it unpublished.
How can I update Portainer without losing its settings?
Keep the portainer_data volume and replace only the Portainer container during a planned update. Docker containers and images managed by Portainer are separate from that volume, but you should still back up the volume before changing versions.