How to Install Docker on a VPS (Ubuntu & Debian Step-by-Step Guide)

Docker is one of the most popular ways to run applications in isolated containers. In today’s guide, we’ll dive into how to install it on a VPS.

We’ll cover how to install Docker Engine on a VPS running Ubuntu or Debian, including Ubuntu 22.04, 24.04 and 26.04 LTS, and Debian 12 and 13. At the end, you’ll also find a cheat sheet with the Docker commands you’re most likely to use every day.

Why use Docker on an unmanaged VPS?

Unlike shared plans, an unmanaged cloud infrastructure gives you complete authority over runtime configurations. A Docker VPS hosting setup is ideal for running web apps, APIs, CI/CD tools, and self-hosted services. Containers rely heavily on the host’s disk performance, especially during Docker build operations and database executions. Our hardware provides optimized RAM and DISK resources to ensure fast layer exporting and low I/O wait times.

What are the requirements to install Docker on VPS nodes manually?

  • A 64-bit VPS running a supported Ubuntu or Debian release: Ubuntu 22.04 LTS (Jammy), 24.04 LTS (Noble) or 26.04 LTS (Resolute), or Debian 12 (Bookworm) or 13 (Trixie) (1)(2).
  • Root access or an administrative user with sudo privileges.
  • An active internet connection to download official security packages.

Step-by-step instructions to install Docker on VPS

First, connect to your server using an SSH client: ssh root@YOUR_SERVER_IP (see how to set up SSH if this is your first connection). Docker recommends removing distribution-provided older packages before installing the official Docker Engine. The Docker Ubuntu install steps below are the same on 22.04, 24.04, and 26.04.

1. Remove conflicting packages

For Ubuntu systems, execute:

for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove -y $pkg; done

For Debian setups, run:

for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove -y $pkg; done

2. Configure the GPG keys and repositories

Update your local package index and download the required certificates:

sudo apt-get update
sudo apt-get install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings

Next, download Docker’s official keyring file. For an install Docker on Ubuntu VPS pipeline, run:

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

Then, append the official repository to your sources list:

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

If you are deploying on a Debian machine, download the keyring file using this path:

sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

Then register the corresponding repository configuration:

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

3. Install and verify Docker Engine

Now, update your system indexes again and install the core components, including the Docker VPS plugins:

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

To verify the installation, download and run the official test container:

sudo docker run hello-world

If you see “Hello from Docker!”, the engine works. On Ubuntu and Debian, the Docker service starts automatically on every boot.

Running your first multi-container stack

Modern developers utilize Docker Compose (now called Docker Compose without the hyphen) to handle complex, multi-layered services. You can define your entire software stack inside a single configuration file.

Create a simple docker-compose.yml file to launch an automated Nginx deployment:

services:
  web:
    image: nginx:latest
    ports:
      - "80:80"
    restart: always

Initialize your service in the background using: docker compose up -d.

Critical firewall security considerations

By default, Docker manipulates iptables routing rules directly. This means it can bypass your local UFW firewall restrictions and expose ports publicly unless explicitly restricted.

That’s why you should always verify your actively listening network interfaces using sudo ss -tulpn. If you’re operating a high-security environment, consider routing incoming web traffic through an internal container network managed by a Reverse Proxy like Nginx or Traefik. 

Docker commands cheat sheet

Once Docker is running on your Linux VPS, these are the commands you’ll reach for most often:

TaskCommand
List running / all containersdocker ps / docker ps -a
Restart a containerdocker restart web
Restart the Docker servicesudo systemctl restart docker
Remove a containerdocker rm web (-f if it’s running)
Remove an imagedocker rmi nginx:1.27
Tag an imagedocker tag myapp:latest registry.example.com/myapp:1.0
Clean up unused datadocker system prune

Key takeaway

Docker makes it easy to deploy and manage applications on a VPS using lightweight, isolated containers.

With Docker Engine and Compose, you can run multi-container applications, automate restarts, and handle deployments with just a few simple commands. Ready to get started? Configure your VPS today.

Frequently Asked Questions about Docker VPS setups

What is the difference between Docker and a VPS?
A VPS is a virtualized operating system slice with dedicated limits, while Docker is an application-level containment engine that runs isolated applications inside that operating system without full kernel overhead.
How do I run Docker commands without sudo?
You can add your user handle to the system group via sudo usermod -aG docker $USER. Log out and reconnect to the terminal for the permissions to apply.
Is container application configuration managed by support?
No. Because these are unmanaged services, our technical support covers the hardware availability and essential network routing. Managing your local container code or fixing broken docker-compose files are handled by the user.

About the author

mvps

MVPS.net provides reliable, high-quality VPS services at competitive prices. The team has extensive experience in virtualized environments and focuses on delivering consistent performance and stability. Services are available across multiple locations without compromising quality — feel free to get in touch to learn more.

By mvps

Categories