Installing Docker and Docker Compose on Ubuntu and Debian

Docker runs applications in isolated containers, with everything they need already packaged. With Docker Compose, you describe several services in a single file and start them all with one command. This tutorial installs the official, up-to-date versions of both on a VPS running Ubuntu (22.04, 24.04 or 26.04) or Debian (12 or 13), using Docker's own repository.

Installing Docker and Docker Compose

Log in to the server as root and run the commands below. They add Docker's official repository (automatically detecting whether the system is Ubuntu or Debian) and install Docker Engine with the Compose plugin:

# apt update
# apt install -y ca-certificates curl
# install -m 0755 -d /etc/apt/keyrings
# . /etc/os-release
# curl -fsSL https://download.docker.com/linux/$ID/gpg -o /etc/apt/keyrings/docker.asc
# chmod a+r /etc/apt/keyrings/docker.asc
# echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/$ID $VERSION_CODENAME stable" > /etc/apt/sources.list.d/docker.list
# apt update
# apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Check that everything is installed by running the test container:

# docker run --rm hello-world
# docker compose version
The message "Hello from Docker!" confirms Docker is working. The service is already running and starts automatically with the server.

Running your first service with Docker Compose

Create a folder for the project and, inside it, a compose.yaml file. As an example, we will publish an Nginx web server on port 8080:

# mkdir -p /root/myproject && cd /root/myproject
# nano compose.yaml
Paste the content below and save the file:

services:
  web:
    image: nginx:alpine
    ports:
      - "8080:80"
    restart: unless-stopped
Now start the service in the background:

# docker compose up -d
Done: open http://SERVER-IP:8080 in your browser and you will see the Nginx welcome page. The server IP address is in your account panel.

Everyday commands

Always from inside the project folder:

  • docker compose ps: lists the project containers and their state;
  • docker compose logs -f: follows the logs in real time;
  • docker compose pull && docker compose up -d: downloads the newest image versions and recreates the containers;
  • docker compose down: stops and removes the containers (volumes with data are kept).
With the restart: unless-stopped option, containers come back on their own after a server reboot. Keep in mind that ports published by Docker are reachable from the internet; publish only what you need and prefer an HTTPS proxy in front of your applications, as in the n8n tutorial.
If you have any difficulties, open a support ticket: Open ticket