How to Install Docker on Ubuntu – Beginner-Friendly Guide
Krisha Arya

Krisha Arya @krisha_arya_55

About: Enthusiastic

Joined:
Sep 5, 2024

How to Install Docker on Ubuntu – Beginner-Friendly Guide

Publish Date: Apr 11
0 0

What is Docker?
Docker is an open-source platform that helps you build, ship, and run applications inside containers. Containers are lightweight, portable units that package code, dependencies, and system tools needed to run an application—ensuring consistency across environments.

Why Use Docker?
🧱 Simplifies deployment

💻 Makes applications portable

⚙️ Runs the same on all systems

📦 Saves system resources with containerized apps

Prerequisites

  • You need a 64-bit Ubuntu system (20.04 or later recommended).
  • You should have sudo/root access.
  • Internet connection 😄

Step-by-Step Installation
1️⃣ Update Your System

sudo apt update
sudo apt upgrade -y
Enter fullscreen mode Exit fullscreen mode

2️⃣ Install Required Packages

sudo apt install ca-certificates curl gnupg lsb-release -y
Enter fullscreen mode Exit fullscreen mode

3️⃣ Add Docker’s 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
Enter fullscreen mode Exit fullscreen mode

4️⃣ Add Docker Repo to APT Sources

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
Enter fullscreen mode Exit fullscreen mode

5️⃣ Update Package List & Install Docker

sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
Enter fullscreen mode Exit fullscreen mode

6️⃣ Verify Installation

docker --version
Enter fullscreen mode Exit fullscreen mode

7️⃣ Run a Test Container

docker run hello-world
Enter fullscreen mode Exit fullscreen mode

You should see a success message from the Docker daemon 🎉

Common Errors & Fixes

  • Permission denied: Run with sudo or add user to Docker group.
  • GPG key issues: Ensure your key file path is correct.
  • Old version?: Uninstall with sudo apt remove docker docker-engine and repeat steps.

Summary

sudo apt update && sudo apt upgrade -y
sudo apt install ca-certificates curl gnupg lsb-release -y
sudo mkdir -p /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 $(lsb_release -cs) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
docker --version
docker run hello-world
Enter fullscreen mode Exit fullscreen mode

Conclusion
That’s it! You’ve successfully installed Docker on your Ubuntu system. You’re now ready to build, run, and manage containers like a pro 💪

Comments 0 total

    Add comment