Skip to content

How to install Docker on a Linux VPS

By Onehost Team1 min read

Docker lets you package applications and their dependencies into portable containers that run the same way everywhere. Here's how to install it on an Ubuntu or Debian VPS.

1. Install Docker Engine

sudo apt update
sudo apt install ca-certificates curl gnupg -y
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release; echo $VERSION_CODENAME) stable" | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y

2. Verify the install

sudo docker run hello-world

If you see the welcome message, Docker is working.

3. Run Docker without sudo (optional)

sudo usermod -aG docker $USER
# log out and back in for this to take effect

4. Run your first real container

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

Visit your server's IP and you'll see the Nginx welcome page, served from a container.

5. Use Docker Compose for multi-container apps

Create a docker-compose.yml to run several services together (for example, an app plus a database), then start them with:

docker compose up -d

Resource tips

Docker itself is lightweight, but your containers still need CPU and RAM. A KVM VPS gives containers their own kernel and isolation from other customers. On a Onehost Linux VPS, your RAM and storage are allocated to your VPS, while vCPU cores are shared on the host (see our Terms of Service), so size the plan's RAM for the containers you run.

Put it into practice

NVMe storage and up to 8 vCPU for heavier workloads.

High Performance VPS