DEV Community

Cover image for Install Docker on Ubuntu
Md Abu Musa
Md Abu Musa

Posted on

1

Install Docker on Ubuntu

To install Docker on Ubuntu, follow these steps:


1. Uninstall Old Versions (Optional)

If you have older versions of Docker installed, remove them:

sudo apt-get remove docker docker-engine docker.io containerd runc
Enter fullscreen mode Exit fullscreen mode

2. Update Package Information

Update your existing package list:

sudo apt-get update
Enter fullscreen mode Exit fullscreen mode

3. Install Required Packages

Install necessary prerequisites for Docker:

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

4. Add Docker’s Official GPG Key

Add Docker's official GPG key for verifying the repository:

sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
Enter fullscreen mode Exit fullscreen mode

5. Set Up the Docker Repository

Add the Docker repository to your 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
Enter fullscreen mode Exit fullscreen mode

6. Update the Package Index

Update the package index to include the Docker repository:

sudo apt-get update
Enter fullscreen mode Exit fullscreen mode

7. Install Docker Engine

Install Docker Engine, containerd, and Docker CLI:

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

8. Verify Docker Installation

Check if Docker is installed and running:

sudo docker --version
sudo docker run hello-world
Enter fullscreen mode Exit fullscreen mode

9. Optional: Run Docker Without sudo

To allow your user to run Docker without sudo:

sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker
Enter fullscreen mode Exit fullscreen mode

Test again by running:

docker run hello-world
Enter fullscreen mode Exit fullscreen mode

This will install Docker and set it up properly on your Ubuntu system.

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More