Install Docker on Ubuntu 22.04

This article is going to teach you how to Install Docker on Ubuntu 22.04. Docker is a group of platform as a service (PaaS) solutions that provide software in containers using OS-level virtualization. There are two tiers to the service: free and premium. Containers are self-contained, containing their own software, libraries, and configuration files, and communicating with one another via well-defined channels. Containers require fewer resources than virtual machines since they all share the services of a single operating system kernel. Docker Engine is the program that runs the containers. Docker, Inc. founded it in 2013 and continues to develop it.

How to Install Docker on Ubuntu 22.04

  • To install Docker on Ubuntu 22.04 start by updating your system using the command below.
sudo apt update
  • Next run the command below to Install Docker on Ubuntu 22.04.
sudo apt install docker.io

Sample output

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  galera-4 libaio1 libconfig-inifiles-perl
  libdbd-mariadb-perl libfprint-2-tod1
  libhtml-template-perl libllvm9 libmariadb3
  libpmem1 libreadline5 libterm-readkey-perl
  mariadb-client-10.7 mariadb-client-core-10.7
  mariadb-common mariadb-server-10.7
  mariadb-server-core-10.7 socat
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  bridge-utils containerd git git-man liberror-perl
  pigz runc ubuntu-fan
Suggested packages:
  ifupdown aufs-tools btrfs-progs cgroupfs-mount
  | cgroup-lite debootstrap docker-doc rinse
  zfs-fuse | zfsutils git-daemon-run
  | git-daemon-sysvinit git-doc git-el git-email
  git-gui gitk gitweb git-cvs git-mediawiki git-svn
The following NEW packages will be installed:
  bridge-utils containerd docker.io git git-man
  liberror-perl pigz runc ubuntu-fan
0 upgraded, 9 newly installed, 0 to remove and 7 not upgraded.
Need to get 79.6 MB of archives.
After this operation, 398 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 pigz amd64 2.4-1 [57.4 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu focal/main amd64 bridge-utils amd64 1.6-2ubuntu1 [30.5 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 runc amd64 1.0.1-0ubuntu2~20.04.1 [4,155 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 containerd amd64 1.5.5-0ubuntu3~20.04.1 [33.0 MB]
Get:5 http://us.archive.ubuntu.com/ubuntu focal-updates/universe amd64 docker.io amd64 20.10.7-0ubuntu5~20.04.2 [36.9 MB]
Get:6 http://us.archive.ubuntu.com/ubuntu focal/main amd64 liberror-perl all 0.17029-1 [26.5 kB]
Get:7 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 git-man all 1:2.25.1-1ubuntu3.2 [884 kB]
Get:8 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 git amd64 1:2.25.1-1ubuntu3.2 [4,554 kB]
Get:9 http://us.archive.ubuntu.com/ubuntu focal/main amd64 ubuntu-fan all 0.12.13 [34.5 kB]
Fetched 79.6 MB in 6min 5s (218 kB/s)               
Preconfiguring packages ...
Selecting previously unselected package pigz.
(Reading database ... 201538 files and directories cu
rrently installed.)
Preparing to unpack .../0-pigz_2.4-1_amd64.deb ...
Unpacking pigz (2.4-1) ...
Selecting previously unselected package bridge-utils.
Preparing to unpack .../1-bridge-utils_1.6-2ubuntu1_a
md64.deb ...
Unpacking bridge-utils (1.6-2ubuntu1) ...
Selecting previously unselected package runc.
Preparing to unpack .../2-runc_1.0.1-0ubuntu2~20.04.1
_amd64.deb ...
Unpacking runc (1.0.1-0ubuntu2~20.04.1) ...
Selecting previously unselected package containerd.
Preparing to unpack .../3-containerd_1.5.5-0ubuntu3~2
0.04.1_amd64.deb ...
Unpacking containerd (1.5.5-0ubuntu3~20.04.1) ...
Selecting previously unselected package docker.io.
Preparing to unpack .../4-docker.io_20.10.7-0ubuntu5~
20.04.2_amd64.deb ...
Unpacking docker.io (20.10.7-0ubuntu5~20.04.2) ...
Selecting previously unselected package liberror-perl
.
Preparing to unpack .../5-liberror-perl_0.17029-1_all
.deb ...
Unpacking liberror-perl (0.17029-1) ...
Selecting previously unselected package git-man.
Preparing to unpack .../6-git-man_1%3a2.25.1-1ubuntu3
.2_all.deb ...
Unpacking git-man (1:2.25.1-1ubuntu3.2) ...
Selecting previously unselected package git.
Preparing to unpack .../7-git_1%3a2.25.1-1ubuntu3.2_a
md64.deb ...
Unpacking git (1:2.25.1-1ubuntu3.2) ...
Selecting previously unselected package ubuntu-fan.
Preparing to unpack .../8-ubuntu-fan_0.12.13_all.deb 
...
Unpacking ubuntu-fan (0.12.13) ...
Setting up runc (1.0.1-0ubuntu2~20.04.1) ...
Setting up liberror-perl (0.17029-1) ...
Setting up bridge-utils (1.6-2ubuntu1) ...
Setting up pigz (2.4-1) ...
Setting up git-man (1:2.25.1-1ubuntu3.2) ...
Setting up containerd (1.5.5-0ubuntu3~20.04.1) ...
Created symlink /etc/systemd/system/multi-user.target
.wants/containerd.service → /lib/systemd/system/conta
inerd.service.
Setting up ubuntu-fan (0.12.13) ...
Created symlink /etc/systemd/system/multi-user.target
.wants/ubuntu-fan.service → /lib/systemd/system/ubunt
u-fan.service.
Setting up docker.io (20.10.7-0ubuntu5~20.04.2) ...
Adding group `docker' (GID 135) ...
Done.
Created symlink /etc/systemd/system/multi-user.target
.wants/docker.service → /lib/systemd/system/docker.se
rvice.
Created symlink /etc/systemd/system/sockets.target.wa
nts/docker.socket → /lib/systemd/system/docker.socket
.
Setting up git (1:2.25.1-1ubuntu3.2) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for systemd (245.4-4ubuntu3.15) .
..
  • After the installation is complete, run the command below to start Docker service.
sudo systemctl start docker.service
  • Docker should be running, to confirm run the command below.
systemctl status docker

Sample output

● docker.service - Docker Application Container Engi>
     Loaded: loaded (/lib/systemd/system/docker.serv>
     Active: active (running) since Fri 2022-02-25 1>
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 9744 (dockerd)
      Tasks: 10
     Memory: 47.1M
     CGroup: /system.slice/docker.service
             └─9744 /usr/bin/dockerd -H fd:// --cont>

Feb 25 14:35:00 ubuntu dockerd[9744]: time="2022-02->
Feb 25 14:35:00 ubuntu dockerd[9744]: time="2022-02->
Feb 25 14:35:00 ubuntu dockerd[9744]: time="2022-02->
Feb 25 14:35:00 ubuntu dockerd[9744]: time="2022-02->
Feb 25 14:35:01 ubuntu dockerd[9744]: time="2022-02->
Feb 25 14:35:01 ubuntu dockerd[9744]: time="2022-02->
Feb 25 14:35:01 ubuntu dockerd[9744]: time="2022-02->
Feb 25 14:35:01 ubuntu dockerd[9744]: time="2022-02->
Feb 25 14:35:01 ubuntu systemd[1]: Started Docker Ap>
Feb 25 14:35:01 ubuntu dockerd[9744]: time="2022-02->
  • In case you want docker to run automatically on Ubuntu 22.04 every time you turn on your system, enable that functionality using the following command.
sudo systemctl enable docker.service
  • Check Docker version you installed using the command below.
sudo docker version

Sample output

Client:
 Version:           20.10.7
 API version:       1.41
 Go version:        go1.13.8
 Git commit:        20.10.7-0ubuntu5~20.04.2
 Built:             Mon Nov  1 00:34:17 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          20.10.7
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.8
  Git commit:       20.10.7-0ubuntu5~20.04.2
  Built:            Fri Oct 22 00:45:53 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.5.5-0ubuntu3~20.04.1
  GitCommit:        
 runc:
  Version:          1.0.1-0ubuntu2~20.04.1
  GitCommit:        
 docker-init:
  Version:          0.19.0
  GitCommit:  

Create Docker Container on Ubuntu 22.04

  • To download any software, use the docker pull command followed by the name of the package. e.g.
docker pull hello-world

Sample output

Using default tag: latest
latest: Pulling from library/hello-world
2db29710123e: Pull complete 
Digest: sha256:97a379f4f88575512824f3b352bc03cd75e239179eea0fecc38e597b2209f49a
Status: Downloaded newer image for hello-world:latest
docker.io/library/hello-world:latest

Run Docker Image on Ubuntu 22.04

  • Run the downloaded image using docker run command followed by package name. e.g.
docker run hello-world

Sample output

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/
  • List all containers using the command below.
docker container ls -a

Sample output

CONTAINER ID   IMAGE         COMMAND    CREATED          STATUS                      PORTS     NAMES
8b3d4ba1ef31   hello-world   "/hello"   20 minutes ago   Exited (0) 20 minutes ago             youthful_wozniak
  • To get a list of all the Docker images that have been installed type the following command.
docker images
  • Use the following command to see the current CPU, RAM, and network use of running images.
docker stats
  • Check Docker’s network configuration using the command below.
docker network ls
  • You can start docker using docker start command followed by container ID e.g.
docker start 8b3d4ba1ef31
  • To stop docker container, use docker stop command followed by container ID.
docker stop 8b3d4ba1ef31
  • You have reached the end of the article, Congratulations. You have learned how to Install docker on Ubuntu 22.04.

    Read more on Docker Documentation

Other Tutorials

Install Squid Proxy on Ubuntu 22.04

Install Syncthing on Ubuntu 22.04

Install Ajenti Control Panel on Ubuntu 22.04

System administrator | Software Developer | DevOps

Leave a Comment