Docker is an open platform for developing, build, shipping, running the applications very quickly and bundle our software into standardized units called containers. When you install the docker engine or daemon have to install all the necessary elements which the software needs to run including libraries, system tools, code, and runtime. We are able to easily manage our infrastructure in the same ways you manage your applications. This Post will help you how to install Docker Engine in your machine.

Update your packages in your system,

$ sudo apt-get update


Install depedency packages using the command below,

sudo apt-get install apt-transport-https ca-certificates

Output:
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,512 B of archives.
After this operation, 169 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://in.archive.ubuntu.com/ubuntu jammy/universe amd64 apt-transport-https all 2.4.5 [1,512 B]
Fetched 1,512 B in 0s (14.1 kB/s)               
Selecting previously unselected package apt-transport-https.
(Reading database ... 218389 files and directories currently installed.)
Preparing to unpack .../apt-transport-https_2.4.5_all.deb ...
Unpacking apt-transport-https (2.4.5) ...
Setting up apt-transport-https (2.4.5) ...


Add the GPG key for the official Docker repository to your system,


$ sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Output;

Warning: apt-key is deprecated. Manage keyring files in tru
sted.gpg.d instead (see apt-key(8)).
OK


Error:

If you may received an error when you use the curl command for add the repository apt-key in your machine, Install the curl package or refer this link  
sudo: curl: command not found


Solution:

Install CURL package:
$ apt-get install curl


Add the Docker repository to APT sources using the command below,

$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable"

output:
Repository: 'deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable'
Description:
Archive for codename: xenial components: stable
More info: https://download.docker.com/linux/ubuntu
Adding repository.
Press [ENTER] to continue or Ctrl-c to cancel.
...
...
Hit:8 https://ppa.launchpadcontent.net/obsproject/obs-studio/ubuntu jammy InRelease
Fetched 87.2 kB in 1s (78.5 kB/s)
Reading package lists... Done
W: https://download.docker.com/linux/ubuntu/dists/xenial/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.


Update the system with recently updated repository
 
$ sudo apt-get update 


Finally execute the command to install the docker community endition in your machine,

$ sudo apt-get install docker-ce


Suggested packages:
  aufs-tools cgroupfs-mount | cgroup-lite
The following NEW packages will be installed:
  containerd.io docker-ce docker-ce-cli docker-ce-rootless-extras docker-scan-plugin libslirp0 pigz slirp4netns
0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
Need to get 107 MB of archives.
After this operation, 466 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y


Check the Docker version,

$ docker -v

Docker version 20.10.7, build f0df350


If you may received an eror when access the docker containers,
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/json: dial unix /var/run/docker.sock: connect: permission denied

Soltutions are here: https://www.thelinuxfaq.com/765-resolved-got-permission-denied-while-trying-to-connect-to-the-docker-daemon-sock