To install Docker on an Ubuntu system, follow these steps:
Step 1: Update the System
Ensure your package index is up-to-date.
sudo apt update
sudo apt upgrade -y
Step 2: Install Prerequisites
Install required packages for Docker.
sudo apt install -y ca-certificates curl gnupg lsb-release
Step 3: Add Docker’s Official GPG Key
Add Docker’s GPG key for secure package verification.
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: Set Up the Docker Repository
Add Docker’s repository to your system’s sources list.
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
Step 5: Install Docker Engine
Update the package index again and install Docker.
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Step 6: Verify Installation
Check if Docker is installed correctly.
sudo docker --version
Step 7: Start and Enable Docker
Ensure Docker runs on startup.
sudo systemctl start docker
sudo systemctl enable docker
Step 8: Run Docker Without sudo
(Optional)
Allow your user to run Docker commands without sudo
.
sudo usermod -aG docker $USER
Note: Log out and log back in for the group changes to take effect.
Step 9: Test Docker
Run a test container to verify everything works.
docker run hello-world
You’re all set! 🎉 Docker should now be installed and running on your Ubuntu system.
If still you’re not able to do so, connect with us at [email protected]