Skip to main content

Install Docker on Ubuntu

·1 min· loading · loading · ·
Docker - This article is part of a series.
Part 1: This Article

Installing Docker on Ubuntu is easy! Follow these steps to get Docker running on your system.

Step 1: Update and Install Required Packages
#

sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings

Step 2: Add Docker’s Official GPG Key
#

sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

Step 3: Add Docker Repository
#

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

Step 4: Install Docker
#

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Step 5: Verify Installation
#

sudo docker run hello-world

Step 6: Enable Docker on Boot
#

sudo systemctl enable docker.service
sudo systemctl enable containerd.service

Step 7: Optional: Update & Upgrade System
#

sudo apt update
sudo apt upgrade

Step 8: Manage Docker as a Non-root User
#

sudo groupadd docker
sudo usermod -aG docker <user>
sudo usermod -aG docker ubuntu
sudo reboot

After reboot, test Docker without sudo:

docker ps

Congratulations! Docker is now installed and ready to use.

For more info, you can check the official Docker docs: Install Docker Engine on Ubuntu.

 Author
Author
Wassim Bejaoui
Security Engineer
Docker - This article is part of a series.
Part 1: This Article