If you're working with containers, Docker is one of the most essential tools you’ll need. In this guide, I’ll walk you through installing the Docker CLI (along with the Docker Engine) on an Ubuntu system in a simple and practical way.
Prerequisites
Before you start, make sure:
- You’re using an Ubuntu system (18.04 or later recommended)
- You have a user account with sudo privileges
- Your system is connected to the internet
Steps
Step 1: Update Package Index
Start by updating your system’s package list:
sudo apt update
Install required dependencies:
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
Step 2: Add Docker’s Official GPG Key
This ensures packages are verified and trusted:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Step 3: Add Docker Repository
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Step 4: Install Docker Engine & CLI
Update package list again:
sudo apt update
Now install Docker:
sudo apt install -y docker-ce docker-ce-cli containerd.io
Step 5: Start and Enable Docker
Start Docker service:
sudo systemctl start docker
Enable Docker to start on boot:
sudo systemctl enable docker
Step 6: Run Docker Without sudo (Optional but Recommended)
By default, Docker requires sudo. To avoid that, add your user to the Docker group:
sudo usermod -aG docker $USER
Apply the changes immediately:
newgrp docker
Step 7: Verify Installation
Check Docker system info:
docker info
List running containers:
docker ps
Quick Note
- docker-ce → Docker Engine
- docker-ce-cli → Docker CLI
- containerd.io → Container runtime
No comments:
Post a Comment