← Back to Blog

How to Run Docker on a VPS (2026)

Published May 4, 2026 · 7 min read · Galaxy Cloud Solutions

Docker on a VPS is one of the most useful combinations in self-hosting. You get portable, isolated containers that are easy to deploy, update, and remove without touching the rest of the server. Once you understand the basics, deploying a new application becomes a matter of running one command.

⚡ KVM VPS with Docker support from $5/mo — Use code LAUNCH2026 for 50% off

Why Docker Needs KVM Virtualization

Docker requires kernel namespaces and cgroups, which are only available on KVM virtual machines. OpenVZ containers share a kernel and cannot run Docker properly. If you are on an OpenVZ VPS and Docker is not working, this is why. All Galaxy Cloud Solutions plans use KVM, so Docker works out of the box.

Step 1: Install Docker

The cleanest way to install Docker on Ubuntu is using the official install script:

curl -fsSL https://get.docker.com | bash
sudo systemctl enable --now docker
sudo usermod -aG docker $USER
newgrp docker

The last two commands let you run Docker without sudo. Log out and back in if the group change does not take effect immediately.

Step 2: Verify the Install

docker run hello-world

If you see a message saying "Hello from Docker!" everything is working.

Step 3: Install Docker Compose

Docker Compose lets you define multi-container applications in a single file. It is included with the Docker install as a plugin:

docker compose version

If that does not work, install it manually:

sudo apt install -y docker-compose-plugin

Running Your First Container

Pull and run an Nginx web server:

docker run -d --name mynginx -p 80:80 nginx

Visit your server IP in a browser and you will see the Nginx welcome page. The -d flag runs it in the background, --name gives it a name, and -p 80:80 maps port 80 on your VPS to port 80 in the container.

Using Docker Compose

For anything more complex, Docker Compose is the right tool. Create a docker-compose.yml file:

version: '3'
services:
  web:
    image: nginx
    ports:
      - "80:80"
    volumes:
      - ./html:/usr/share/nginx/html
    restart: unless-stopped

Then start it with:

docker compose up -d

Useful Docker Commands

docker ps                    # List running containers
docker ps -a                 # List all containers including stopped
docker logs container_name   # View container logs
docker exec -it container_name bash  # Shell into a running container
docker stop container_name   # Stop a container
docker rm container_name     # Remove a container
docker images                # List downloaded images
docker system prune          # Clean up unused containers and images

Keeping Containers Updated

docker pull image_name:latest
docker compose down && docker compose up -d

What to Run in Docker

Almost anything that has a public Docker image. Popular choices for self-hosting on a VPS include Nextcloud, Vaultwarden, Gitea, n8n, Uptime Kuma, Jellyfin, and dozens of other applications. Most have official images on Docker Hub with one-command setup.

Docker-ready KVM VPS from $5/mo

All Galaxy Cloud Solutions plans use KVM virtualization — Docker works out of the box. One-click Docker installer in the dashboard. Use code LAUNCH2026 for 50% off your first month.

Get Started