Install Docker – Ubuntu

Installing Docker on Linux can be tricky. Follow the instructions step by step.

Check the Ubuntu release version

lsb_release -d

Update the apt package

  • Update the apt package index and install packages to allow apt to use a repository over HTTPS:
sudo apt-get update

sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lab-release \

Add Docker’s official GPG key

sudo mkdir -p /etc/apt/keyrings

curl -fsSL | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

Set up the Docker repositories

echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Install Docker packages

sudo chmod a+r /etc/apt/keyrings/docker.gpg

sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli docker-compose-plugin

sudo apt-mark hold docker-ce

Confirm Installation of Docker

sudo docker version

Use Docker as a non-root user

sudo usermod -aG docker <user-name>

docker version
  • You need to log out and log in again.

Run docker

docker run hello-world
docker image ls

Leave a Comment

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s