How to Install Docker on Ubuntu 22.04 Quickly

This guide will help you to install docker on Ubuntu 22.04 quickly using the repository.

Installation methods

You can install Docker Engine in different ways, depending on your needs:

  • Most users set up Docker’s repositories and install from them, for ease of installation and upgrade tasks. This is the recommended approach.
  • Some users download the DEB package and install it manually and manage upgrades completely manually. This is useful in situations such as installing Docker on air-gapped systems with no access to the internet.
  • In testing and development environments, some users choose to use automated convenience scripts to install Docker.

In this tutorial, you will install Docker using the repository.

Install using the repository

Before you install Docker Engine for the first time on a new host machine, you need to set up the Docker repository. Afterward, you can install and update Docker from the repository.

1. Set up the repository

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 ca-certificates curl gnupg lsb-release -y

Add Docker’s official GPG key

sudo mkdir -p /etc/apt/keyrings

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

Use the following command to set up the repository

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

2. Install Docker Engine

Update the apt package index, and install the latest version of Docker Engine, containerd, and Docker Compose, or go to the next step to install a specific version

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

Verify that Docker Engine is installed correctly by running the hello-world image.

sudo docker run hello-world

This command downloads a test image and runs it in a container. When the container runs, it prints a message and exits. If you see this message, this means you install Docker successfully.

How to Install Docker on Ubuntu 22.04

Cleaning hello-world container and image

Show exited container to find CONTAINER ID

sudo docker ps -a

You can see the container id 4e264c71fe24. Run command docker container rm container-id to remove the container

sudo docker container rm 4e264c71fe24

Finally, remove hello-word image

sudo docker rmi hello-world:latest

Please check this guide if you want to install Docker Compose on Ubuntu 22.04

Reference: Docker.com

Leave a Reply

Your email address will not be published.

How to Schedule a Python Script Reminder for System Health Check?

How To Upgrade Zabbix Server 4.0.X To 5.0.X On Centos 7?

How To Set Never Expired Password For vCenter SSO Users?

How to use Python Virtualenv and Virtualenvwrapper on Windows

How to Install Docker Compose on Ubuntu 22.04

How to Setup RabbitMQ Cluster for vCloud Director 9.7?