How to install Docker on Ubuntu 22.04

One of the most brilliant technologies of recent times is Docker. With it, you can deploy applications in the form of containers, ensuring the integrity of the same so that there are no execution problems. Today, you will learn how to install Docker on Ubuntu 22.04.

Introduction to Docker

Docker is a platform created for developing, deploying and running applications inside containers.

So, we will have to answer the question of what is a container? A container is a set of standardized executable components that combine the application source code with the operating system (OS) libraries and dependencies needed to run that code in any environment.

In other words, a container is a kind of package that includes everything needed for an application to run in an environment. This may sound like snap or flatpak, but it goes much further. **Because a container also includes the entire operating system.

So, the management of a container makes that you can run and install an application in a fast, easy but above all safe way. Therefore, there will be no compatibility problems between the different targets.

Well, what Docker does is to manage them and provide an intermediate layer between it and the operating system.

Let’s install Docker.

Install Docker on Ubuntu 22.04

The recommended method to install Docker is to do it from the special repository for Ubuntu 22.04. This will make you have the latest stable version of it.

So, open a terminal or start a session via SSH, and update the system completely.

sudo apt update
sudo apt upgrade

Next, install some packages needed to add the repository to the system:

sudo apt install apt-transport-https ca-certificates curl software-properties-common.

Thereafter, add the GPG key of the repository

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

Now add the repository:

echo "deb [arch=$$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Refresh APT to load the repository

sudo apt update

Now you are ready to install Docker on Ubuntu 22.04

sudo apt install docker-ce
Install Docker on Ubuntu 22.04
Install Docker on Ubuntu 22.04

As soon as the installation is finished, you can check the status of the tool’s service. In this case, you can do it with.

sudo systemctl status docker
Docker status
Docker status

It should be running and enabled.

In this case, you will be able to play with it.

Optional: Running Docker without root permissions

By default, you need to have root permissions to run Docker commands. This may be uncomfortable for some users, so it is possible to change it.

To achieve this, just add your user to the docker group that was created during installation.

sudo usermod -aG docker ${USER}

Now you can use it without user limitations. You can replace ${USER} with the name of the user you want to add.

Using the Docker command

The docker command is the command you will use frequently when working with this technology. This command also has subcommands that perform the necessary operations.

To consult these subcommands, run

docker
Docker commands help
Docker commands help

Alternatively, you can check the help of each of them individually. Of course, not for all of them, but where you have doubts about the operation.

docker [command] --help

Now, the best way to know if Docker is working properly is to use it to run the test image.

docker run hello-world

You will get an output screen like this:

Using Docker on Ubuntu 22.04
Using Docker on Ubuntu 22.04

This indicates that Docker is perfectly working on the system.

Containers are distributed in the form of images, these can be searched with the following command

docker search [keyword]

For example:

docker search debian

You will get an output similar to this:

NAME DESCRIPTION STARS OFFICIAL AUTOMATED
ubuntu Ubuntu Ubuntu is a Debian-based Linux operating sys... 14547 [OK]       
debian Debian is a Linux distribution that's compos... 4364 [OK]       
neurodebian NeuroDebian NeuroDebian provides neuroscience research sys... 91 [OK]       
webdevops/ansible Ansible image for CentOS, Ubunty, Debian and... 3 [OK] bitnami/debian-base-bu... 3 [OK]
bitnami/debian-base-build-buildpack Debian base compilation image 2 [OK]

And if you want to download and use one then, you can run

docker pull debian

Sample Output:

Using default tag: latest
latest: Pulling from library/debian
1339eaac5b67: Pull complete 
Digest: sha256:859ea45db307402ee024b153c7a63ad4888eb4751921abbef68679fc73c4c739
Status: Downloaded newer image for debian:latest
docker.io/library/debian:latest

You can also check the images you have on the system.

docker images

Sample Output:

REPOSITORY TAG ID IMAGE CREATED SIZE. debian latest d2780094a226 2 weeks ago 124MB hello-world latest feb5d9fea6a5 9 months ago 13.3kB

Remove Docker from the system

If you no longer want to use it, you can uninstall it from the system, with this command

sudo apt remove docker-ce

Then you will no longer have it on your system.

Conclusion

Docker is the most popular in its field because it has been a success for managing containers and mass deployments of applications without the risk of strange performances.

Today, in this post, you learned how to install it and check the generalities about this technology.

I hope you liked it and help us to spread it, so we can grow.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top