How to Install Docker on Ubuntu 22.04 (Step-by-Step)

In this blog post, we will show you how to install Docker on Ubuntu 22.04 step-by-step.

Docker is considered as PaaS (platform as a service) software which makes use of OS level virtualization feature to spin up containers. In other words, we can say Docker provides container run time environment.

Prerequisites

  • Pre-Installed Ubuntu 22.04
  • 2 GB RAM or More
  • 2 CPU cores or more
  • 20 GB hard disk
  • Sudo User with privileges
  • Internet Connectivity

Without any further ado, let’s jump into Docker installation steps,

1) Install Docker Dependencies

Open the terminal and run following commands to install docker dependencies,

$ sudo apt update
$ sudo apt install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common

2) Add Docker APT Repository

Docker package is available in the default package repositories of Ubuntu 22.04 but in order to install latest and stable version of docker, add its official APT repository using following set of commands.

Add Docker’s official GPG key

$ 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

Run beneath command to add official docker apt repository.

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

3) Install Docker on Ubuntu 22.04

The system on which docker is installed, it also called as docker engine. So, to install docker, run

$ sudo apt update
$ sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y

Once the docker is installed, verify it’s service

$ sudo systemctl status docker

Docker-Service-status-Ubuntu-22-04

If you want local user to use docker command without sudo, then add that user to docker group, run

$ sudo usermod -aG docker $USER
$ newgrp docker

Note: To use docker command without sudo, logged and login

$ docker version

Docker-Version-Output-Ubuntu-22

4) Test docker Installation

To test docker installation, try to spin up ‘hello-world’ container using following docker command,

$ docker run hello-world

Docker-run-hello-world-ubuntu-22-04

Above output confirms that docker installation is working correctly. That’s all from this guide, please share your queries and feedback in below comments section.

Also Read: How Set or Change Time Zone in Linux

Leave a Comment

seventeen − four =