Here is the latest guide to install Docker on an Ubuntu VPS:
1. Update System Packages
Always start by updating your system packages to ensure everything is up to date:
sudo apt update
sudo apt upgrade -y
2. Install Dependencies
Install some necessary packages for Docker:
sudo apt install ca-certificates curl gnupg lsb-release -y
3. Add Docker GPG Key
Add the official Docker GPG key to ensure security:
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
4. Add Docker Repository
Add the Docker repository to your sources list to get the latest version:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
5. Update Package Index
Update your package index after adding the Docker repository:
sudo apt update
6. Install Docker Engine
Install Docker Engine, CLI, containerd, Buildx, and Compose plugin:
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
7. Verify Docker Installation
Check if Docker is installed correctly by verifying the version:
docker --version
Example output:
Docker version 24.0.6, build ed223bc
8. Enable and Start Docker
Ensure Docker starts automatically after system boot:
sudo systemctl enable docker
sudo systemctl start docker
9. Optional: Run Docker Without sudo
To run Docker without needing to use sudo, add your user to the Docker group:
sudo usermod -aG docker $USER
Log out and log back in to apply the changes.
Docker is now installed on your Ubuntu VPS! You can start running containers or Docker-based applications.