Many programs are published as Docker images: you start them with one command, and they bring everything they need with them. This page installs Docker and Docker Compose from the Ubuntu packages, starts a first container and, if you want, the web interface Portainer. The commands were tested on Ubuntu 26.04 LTS; run them as root or with sudo.
1. Install Docker
apt install docker.io docker-compose-v2
On Debian 13 the Compose package has another name: apt install docker.io docker-compose. docker compose then works the same way.
Test it:
docker run --rm hello-world
The answer starts with Hello from Docker!.
To use Docker as your normal user without sudo, add the user to the docker group, then log out and in again:
usermod -aG docker alex
Whoever can use Docker can control the whole server. Add only users you would also give the root password to.
2. Start a Container
This starts the web server nginx and makes it reachable on port 8080 of your server. --restart unless-stopped starts it again after a restart of the server.
docker run -d --name web -p 8080:80 --restart unless-stopped nginx
docker ps | List running containers and their ports |
docker logs web | Show what the container writes |
docker stop web / docker start web | Stop and start it |
docker rm -f web | Stop and delete the container (the image stays) |
A port published with -p 8080:80 is reachable from the whole internet, even when ufw is on and has no rule for it. If only programs on the server itself need the port, publish it on 127.0.0.1; then it cannot be reached from outside:
docker run -d --name web -p 127.0.0.1:8080:80 --restart unless-stopped nginx
3. Docker Compose
With Compose you describe your containers in a file and start them all with one command. Create a folder and in it the file compose.yaml:
mkdir -p ~/web && cd ~/web nano compose.yaml
services:
web:
image: nginx
ports:
- "127.0.0.1:8080:80"
restart: unless-stopped
Run these commands in the same folder:
docker compose up -d | Start everything in the background |
docker compose ps | Show the state |
docker compose pull && docker compose up -d | Update to the newest images |
docker compose down | Stop and remove the containers |
4. Portainer: Docker in Your Browser
Portainer shows your containers, logs and images in a web interface.
docker volume create portainer_data docker run -d -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:lts
Open https://YOUR.SERVER.IP:9443. The browser warns about the certificate, because Portainer makes its own; continue to the page. Then create the administrator:
- A user name and a password of at least 12 characters, twice.
- The Setup token. Portainer writes it to its log when it starts; show it on the server with
docker logs portainerand copy the long value aftersetup_token=. - Choose Create user.
On the next screen choose Skip, then Get Started. Open the local environment and then Containers: your containers with their state and published ports.
Port 9443 is open to the internet too (see the warning above). Safer: publish it with -p 127.0.0.1:9443:9443 and open it through an SSH tunnel. On your computer run ssh -L 9443:127.0.0.1:9443 alex@YOUR.SERVER.IP, keep that window open, and open https://localhost:9443.

