Docker is one of the most popular container platforms for developers, DevOps engineers, and businesses. It allows you to deploy applications quickly, isolate services, and simplify software management on your VPS.
In this guide, you'll learn how to install Docker on an Ubuntu VPS in just a few minutes.
Requirements
- Ubuntu 22.04 or Ubuntu 24.04 VPS
- Root access or a user with sudo privileges
- Internet connection
Step 1: Update Your System
Before installing Docker, update all installed packages:
sudo apt update
sudo apt upgrade -y
Step 2: Install Required Packages
sudo apt install ca-certificates curl gnupg lsb-release -y
Step 3: Add Docker's Official GPG Key
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
Step 4: Add Docker Repository
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 > /dev/null
Step 5: Install Docker Engine
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
Step 6: Verify Docker Installation
docker --version
You should see output similar to:
Docker version 28.x.x
Step 7: Test Docker
sudo docker run hello-world
If Docker is installed correctly, a welcome message will appear.
Optional: Run Docker Without sudo
sudo usermod -aG docker $USER
newgrp docker
Now you can execute Docker commands without using sudo.
Useful Docker Commands
docker ps
docker images
docker pull nginx
docker run -d -p 80:80 nginx
docker stop CONTAINER_ID
docker rm CONTAINER_ID
Security Tips
- Keep Ubuntu updated regularly.
- Only expose required ports.
- Use UFW or another firewall.
- Avoid running unnecessary containers as root.
- Keep Docker Engine updated.
Why Use Docker on a VPS?
- Fast application deployment
- Lightweight compared to virtual machines
- Easy scaling
- Ideal for web hosting and APIs
- Supports CI/CD workflows
- Perfect for development and production environments
Need a Reliable Docker VPS?
Docker performs best on a VPS with NVMe SSD storage, dedicated resources, full root access, and a stable network connection. VPS For Life offers Linux VPS hosting optimized for Docker, containers, web applications, APIs, and development environments with fast deployment and worldwide locations.
