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
⚠ The docker group is like root

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 psList running containers and their ports
docker logs webShow what the container writes
docker stop web / docker start webStop and start it
docker rm -f webStop and delete the container (the image stays)
Docker ports ignore the ufw firewall

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 -dStart everything in the background
docker compose psShow the state
docker compose pull && docker compose up -dUpdate to the newest images
docker compose downStop 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:

  1. A user name and a password of at least 12 characters, twice.
  2. The Setup token. Portainer writes it to its log when it starts; show it on the server with docker logs portainer and copy the long value after setup_token=.
  3. Choose Create user.

Portainer asks for the administrator and the setup token

On the next screen choose Skip, then Get Started. Open the local environment and then Containers: your containers with their state and published ports.

The container list in Portainer

💡 Keep Portainer private

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.


Related Guides

View all Ubuntu and Debian guides

Was this answer helpful? 0 Users Found This Useful (0 Votes)