Cyberithub

How to Install docker on Ubuntu 22.04 LTS (Jammy Jellyfish)

Advertisements

In this article, we will see how to install docker on Ubuntu 22.04 LTS (Jammy Jellyfish). Docker is a free and open source platform to build, deploy and host containerized applications. It is much efficient and faster than the virtual machines which required dedicated resources to run independently. Docker containers, on the other hand can share resources like operating system, cpu, memory, file systems etc and still work as an independent entity.

Over the years, docker has emerged as one of the most efficient solution for building and testing applications in different platforms, primarily because of the number of features it provides. Check all the features and use cases of docker on its official website. With the emergence of microservices architecture, docker has now became an integral component of all containerized based architecture.

It can be easily installed in almost all the famous Windows, Linux and Unix based platforms. Here we will look into the steps to install docker on Ubuntu 22.04 LTS based systems in detail. But before that it is important to understand that there are many ways to install docker on Ubuntu 22.04 LTS system, we will follow the most simplistic way here.

 

How to Install docker on Ubuntu 22.04 LTS (Jammy Jellyfish)

How to Install docker on Ubuntu 22.04 LTS (Jammy Jellyfish)

Also Read: How to Install jq(JSON Processor) on Ubuntu 22.04 LTS(Jammy Jellyfish)

Step 1: Prerequisites

a) You should have a running Ubuntu 22.04 LTS Server.

b) You should have a sudo or root access to run privileged commands.

c) You should have apt or apt-get installed in your Server.

 

Step 2: Update Your Server

In the first step, you need to download all the available updates from default Ubuntu repo using sudo apt update command and then upgrade the package to the latest versions by using sudo apt upgrade command as shown below.

cyberithub@ubuntu:~$ sudo apt update && sudo apt upgrade
[sudo] password for cyberithub:
Hit:1 https://dl.google.com/linux/chrome/deb stable InRelease
Hit:2 http://in.archive.ubuntu.com/ubuntu jammy InRelease
Get:3 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Get:4 http://in.archive.ubuntu.com/ubuntu jammy-updates InRelease [119 kB]
Get:5 http://in.archive.ubuntu.com/ubuntu jammy-backports InRelease [108 kB]
Get:6 http://security.ubuntu.com/ubuntu jammy-security/main amd64 DEP-11 Metadata [41.5 kB]
Get:7 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 DEP-11 Metadata [18.5 kB]
Fetched 397 kB in 2s (163 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
18 packages can be upgraded. Run 'apt list --upgradable' to see them.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
.....................................................

 

Step 3: Install docker

You can install docker application from default ubuntu repo by using sudo apt install docker.io command as shown below. This will download and install the application along with all its dependencies.

cyberithub@ubuntu:~$ sudo apt install docker.io
[sudo] password for cyberithub:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
libjq1 libonig5
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-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 0 not upgraded.
Need to get 76.1 MB of archives.
After this operation, 307 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
..............................................

 

Step 4: Check Version

After successful installation, you can check the installed version by using docker --version command as shown below.

cyberithub@ubuntu:~$ docker --version
Docker version 20.10.21, build 20.10.21-0ubuntu1~22.04.2

 

Step 5: Verify Installation

You can also verify the installed files path by using dpkg -L docker.io command as shown below.

cyberithub@ubuntu:~$ dpkg -L docker.io
/.
/etc
/etc/docker
/lib
/lib/systemd
/lib/systemd/system
/lib/systemd/system/docker.service
/lib/systemd/system/docker.socket
/usr
/usr/bin
/usr/bin/docker
/usr/bin/docker-init
/usr/bin/docker-proxy
/usr/bin/dockerd
/usr/share
/usr/share/bash-completion
/usr/share/bash-completion/completions
/usr/share/bash-completion/completions/docker
........................................................

 

Step 6: Verify Service

After installation, by default docker service should be active and in running state. This can be verified by using systemctl status docker command as shown below. In case, it was not running, you can use sudo systemctl start docker or sudo systemctl restart docker command to start or restart the service.

cyberithub@ubuntu:~$ systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2023-04-16 13:38:20 IST; 1min 47s ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 12397 (dockerd)
Tasks: 7
Memory: 22.5M
CPU: 376ms
CGroup: /system.slice/docker.service
└─12397 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
.....................................

 

Step 7: Pull Image

Now that docker is successfully installed in the system, it is time to use the application to pull the images from repository to create a container. To pull any image, you can use sudo docker pull <image_name> syntax. For example, here we are pulling the latest version of ubuntu image by using sudo docker pull ubuntu command as shown below.

cyberithub@ubuntu:~$ sudo docker pull ubuntu
Using default tag: latest
latest: Pulling from library/ubuntu
2ab09b027e7f: Pull complete
Digest: sha256:67211c14fa74f070d27cc59d69a7fa9aeff8e28ea118ef3babc295a0428a6d21
Status: Downloaded newer image for ubuntu:latest
docker.io/library/ubuntu:latest

 

Step 8: List Images

To check the list of images, you need to use sudo docker images command as shown below.

cyberithub@ubuntu:~$ sudo docker images
[sudo] password for cyberithub:
REPOSITORY  TAG     IMAGE ID      CREATED      SIZE
ubuntu      latest  08d22c0ceb15  5 weeks ago  77.8MB

 

Step 9: Create a Container

To create a container from an image, you can use below docker create command. In the below example, we are creating a container called nginx_base using nginx:alpine image with Port 80 exposed to localhost.

cyberithub@ubuntu:~$ sudo docker create --name nginx_base -p 80:80 nginx:alpine
Unable to find image 'nginx:alpine' locally
alpine: Pulling from library/nginx
f56be85fc22e: Pull complete
2ce963c369bc: Pull complete
59b9d2200e63: Pull complete
3e1e579c95fe: Pull complete
547a97583f72: Pull complete
1f21f983520d: Pull complete
c23b4f8cf279: Pull complete
Digest: sha256:dd2a9179765849767b10e2adde7e10c4ad6b7e4d4846e6b77ec93f080cd2db27
Status: Downloaded newer image for nginx:alpine
8f9ef99d01cc8c1e808e1da84293b5a4282704020e73e6e79b5cd932e239f730

 

Step 10: List all Containers

To list all running containers, you can use sudo docker container ls command as shown below. You can check 40 Ultimate docker commands with examples | Cheat Sheet article to know more about docker commands.

cyberithub@ubuntu:~$ sudo docker container ls
CONTAINER ID IMAGE         COMMAND                 CREATED         STATUS        PORTS                              NAMES
8f9ef99d01cc nginx:alpine  "/docker-entrypoint.…"  17 minutes ago  Up 6 seconds  0.0.0.0:80->80/tcp, :::80->80/tcp  nginx_base

Leave a Comment