1. Blog
  2. Manuals

How to Install Docker, Docker Compose and Portainer on a VPS

How to Install Docker, Docker Compose and Portainer on a VPS

Docker runs applications in isolated containers, Docker Compose describes several containers in one file, and Portainer gives you a web interface to manage them. Together they turn a clean VPS into a platform for any self-hosted service. This guide works on Ubuntu 22.04 and 24.04, Debian 12 and 13.

Quick install with one command

The official script detects your distribution, adds the Docker repository and installs every component:

curl -fsSL https://get.docker.com | sudo sh

That is enough for a test or personal server. If you prefer to see each step, use the manual install below.

Manual install from the official repository

Install the prerequisites and add Docker’s repository key:

sudo apt update
sudo apt 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

Add the repository:

echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Install Docker Engine and the plugins:

sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Verify the installation

sudo docker run --rm hello-world
docker compose version

The first command pulls a test image and prints a greeting; the second shows the Compose version.

Run Docker without sudo

Add your user to the docker group:

sudo usermod -aG docker $USER

Log out and back in for the change to apply. Keep in mind that members of the docker group effectively have root access to the server.

Install Portainer

Create a volume for its data and start the container:

docker volume create portainer_data
docker run -d \
  -p 8000:8000 -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 in a browser. It will warn about a self-signed certificate — that is expected, so continue.

After logging in, choose the local environment — that is Docker on your server.

Your first service with Compose

Create a docker-compose.yml file:

services:
  web:
    image: nginx:alpine
    ports:
      - "8080:80"
    restart: unless-stopped

Start it:

docker compose up -d

The service is available at http://your-server-ip:8080 and shows up in Portainer under Stacks. Stop and remove it with docker compose down.

Next steps