Docker simplifies application deployment by isolating software into lightweight containers. If you want to deploy modern applications efficiently, learning how to install docker ubuntu vps is a fundamental skill. This guide walks you through the official installation method using Docker's stable repository.
Prerequisites
Before diving in, ensure your environment meets these requirements:
sudo privileges.---
Step 1: Update Your System
First, update your existing package list to ensure all system components are up to date and to prevent version conflicts before you install docker ubuntu vps.
bashsudo apt update && sudo apt upgrade -yStep 2: Install Required Dependencies
Docker requires a few primitive packages to allow apt to utilize packages over HTTPS. Run the following command to install them:
bashsudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg -yStep 3: Add Docker's Official GPG Key
To ensure the integrity and authenticity of the software you are downloading, add the official Docker GPG key to your system:
bashsudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL [https://download.docker.com/linux/ubuntu/gpg](https://download.docker.com/linux/ubuntu/gpg) | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpgStep 4: Set Up the Docker Repository
Next, register the stable Docker repository with your system's package source list:
bashecho \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] [https://download.docker.com/linux/ubuntu](https://download.docker.com/linux/ubuntu) \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/nullAfter adding the repository, refresh your package index again to include Docker's packages:
bashsudo apt updateStep 5: Install Docker Engine
Now, install the latest version of Docker Engine, CLI, and containerd:
bashsudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -yStep 6: Verify the Installation
Once the installation is complete, verify that the Docker service is running properly on your VPS:
bashsudo systemctl status dockerYou should see an output indicating that the service is active (running). To double-check that the process to install docker ubuntu vps was successful, execute the classic hello-world image:
bashsudo docker run hello-worldIf everything is configured correctly, Docker will download the test image, run it inside a container, print a confirmation message, and exit.
---
Optional: Post-Installation Step (Run Docker Without Sudo)
By default, running any docker command requires sudo privileges. If you prefer not to type sudo every time, add your current user to the docker group:
bashsudo usermod -aG docker $USERNote: To apply these changes, log out of your VPS session and log back in, or run the following command to activate the group changes immediately:
bashnewgrp docker