Docker and Portainer let you run applications in containers and manage them from a web dashboard. This guide walks you through a fresh installation on a DigitalBerg VPS or dedicated server running Ubuntu 24.04 or 22.04 LTS, with Portainer kept private behind an SSH tunnel.
You need administrator access to the server. These instructions are for a normal, rootful Docker installation on Ubuntu, rather than a shared hosting account, rootless Docker or a server already managed by another container platform.

1. Prepare your server for Docker and Portainer
Before making changes, take a recoverable server backup or snapshot. On a server that already hosts websites, databases or customer workloads, arrange a maintenance window and check how the installation will affect existing services.
Connect over SSH using your server’s address and your own account:
ssh your-user@YOUR_SERVER_IP
Replace the placeholders throughout this guide. Run server commands in this SSH session unless a step explicitly says to use your own computer.
cat /etc/os-release
uname -m
df -h
Confirm the Ubuntu version, architecture and available disk space. If Docker or another container runtime is already installed, review it before continuing. Conflicting distribution packages must be resolved using the official Ubuntu installation instructions; do not remove production dependencies blindly.
2. Add Docker’s official Ubuntu repository
Use a dedicated keyring rather than the retired apt-key method. The commands below detect the server’s architecture and Ubuntu codename:
sudo apt update
sudo apt install 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 update
Stop if any command reports an error. Repository warnings, an unsupported release or a failed download should be fixed before installing packages. For Debian, AlmaLinux or another operating system, follow Docker’s instructions for that distribution instead of reusing this Ubuntu repository.
3. Install Docker Engine and check it works
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl enable --now docker
sudo docker run --rm hello-world
sudo docker compose version
The test container should print a confirmation message and exit. The final command checks that the Compose plugin is available for applications that use a compose.yaml file.
These examples retain sudo. Membership of the docker group grants powerful access to the host; only give it to trusted administrators. See Docker’s security guidance before changing access permissions.
4. Deploy Portainer with persistent storage
Docker and Portainer serve different roles: Docker runs your containers, while Portainer provides the management interface. Create a volume for Portainer’s settings, then start its Community Edition container:
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
This adapts the official Portainer CE deployment by binding the dashboard to localhost. It omits port 8000 because this walkthrough does not use Edge agents. The lts tag follows the supported long-term-support release stream; check release compatibility before future upgrades.
Treat Portainer as a server administration tool. Its Docker socket connection can control the host’s containers and access sensitive resources. Keep the dashboard restricted and give administrator accounts only to people you trust.
5. Access Docker and Portainer through an SSH tunnel
On your own computer, open a separate terminal and run:
ssh -N -L 127.0.0.1:9443:127.0.0.1:9443 your-user@YOUR_SERVER_IP
Keep that terminal open. In your browser, visit https://localhost:9443. Connecting directly to https://YOUR_SERVER_IP:9443 is intentionally unavailable with this configuration.
Portainer initially uses a self-signed certificate, so a browser may report a certificate warning. The SSH tunnel does not make that certificate trusted. Verify the endpoint and configure a trusted certificate using Portainer’s certificate instructions before entering credentials; avoid making a habit of bypassing certificate warnings.
Do not open public dashboard ports simply to fix a connection problem. Docker-published ports can bypass UFW rules, so review Docker’s firewall behaviour before exposing any container service.
6. Create your administrator account
Open the interface promptly after starting the container. Current releases require a setup token for a new instance. Retrieve it on the server:
sudo docker logs portainer
Find the setup_token= line, copy the value into the setup screen and create an administrator with a unique password that meets the displayed requirements. Keep the token and logs private. See the setup token FAQ if the field or token is missing.
Follow the initial wizard, skip Edge Compute if you do not need it, and select the automatically detected local environment. Interface labels can vary between releases. The first-time setup guide explains the current screens.
7. Verify Docker and Portainer, then plan maintenance
sudo docker ps --filter name=portainer
sudo docker port portainer
sudo docker logs --tail 50 portainer
Check that the container is running and that port 9443 is bound to 127.0.0.1. In the dashboard, confirm that you can see the local environment and its containers, images, networks and volumes.
Keep a record of your installation choices. Back up Portainer’s configuration and your application databases and volumes separately: a dashboard backup is not a backup of every application it manages. Store recovery copies away from the server and test restoration before relying on them.
Schedule updates for both Docker and Portainer. Review compatibility and release notes, take a backup and use a maintenance window. Pulling a new image alone does not replace a running container.
Troubleshooting Docker and Portainer
The dashboard will not open
Confirm the SSH tunnel is still running, check the server address and SSH port, then inspect the Portainer container and its logs. If local port 9443 is already occupied, use 10443 on the left side of the tunnel mapping and browse to https://localhost:10443.
Portainer says setup has timed out
For a brand-new installation that has not been claimed, restart it with sudo docker restart portainer, retrieve the setup token from the logs again and complete setup promptly. Do not delete the data volume as a troubleshooting shortcut.
The container name is already in use
Inspect the existing container before doing anything else: sudo docker ps -a --filter name=portainer. You may already have an installation with valuable configuration. Do not overwrite or remove it until you understand what it contains.
Docker reports permission denied or cannot connect
Use sudo as shown and check sudo systemctl status docker. A socket or service error needs investigation; making the Docker socket writable by everyone is not an appropriate fix.
Frequently asked questions
Can I use Docker and Portainer on shared hosting?
This walkthrough requires server administrator access. A shared cPanel account normally does not provide the required control. Confirm your plan’s capabilities with DigitalBerg before starting.
Does my application need its own domain?
The private dashboard does not require public DNS. A public application may need a hostname, reverse proxy and HTTPS certificate. Our DNS zone guide explains how to point a hostname at your server; DNS changes alone do not configure the application or its certificate.
Can DigitalBerg help with installation?
If you are unsure about the operating system, existing workloads or available server access, contact DigitalBerg before changing the server. Include the operating system, the failed step and a redacted error message. Never send passwords, private keys or setup tokens.





