HomeCONTAINERSHow To Install Docker CE on Ubuntu 22.04|20.04|18.04

How To Install Docker CE on Ubuntu 22.04|20.04|18.04

Docker is a software development platform based on Containers (lightweight execution environments) that share the operating system kernel but operate independently. Containers have been used on Unix and Linux-based systems for some time; however, when Docker was released in the market in 2013, it became easier for developers to bundle their applications in such a way that it is built once and can be executed anywhere.

This tutorial will show you How to Install Docker CE on Ubuntu 22.04|20.04|18.04.
So let’s get this party started!

Install Docker CE on Ubuntu 22.04|20.04|18.04

Follow the instruction below to install Docker CE on Ubuntu 22.04|20.04|18.04;

Step 1: Update the system

Open the terminal on your Ubuntu 22.04|20.04 and enter the following commands to update system repositories:

sudo apt update && apt upgrade

Step 2: Install the required Dependencies

The following step is to install Docker’s necessary dependencies after updating the system packages:

sudo apt install lsb-release ca-certificates apt-transport-https software-properties-common -y

Step 3: Add Docker repository to System Sources

The Docker installation is made simpler and updates are delivered more quickly when the Docker repository is integrated into the system sources.

Import the Docker GPG key necessary for connecting to the Docker repository before adding the Docker repository to the system sources;

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

Then, to add the Docker repository to your Ubuntu 22.04|20.04|18.04 system sources list, use the following command;

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

Step 4: Update System Packages

After adding the Docker repository to the system sources, update the system packages once more:

sudo apt update

Step 5: Install Docker on Ubuntu 22.04|20.04|18.04

If you carefully followed the preceding procedures, your Ubuntu 22.04|20.04|18.04 system is now prepared for the Docker installation;

sudo apt install docker-ce

Output:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  containerd.io docker-ce-cli docker-ce-rootless-extras docker-scan-plugin git git-man liberror-perl libslirp0 pigz slirp4netns
Suggested packages:
  aufs-tools cgroupfs-mount | cgroup-lite 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:
  containerd.io docker-ce docker-ce-cli docker-ce-rootless-extras docker-scan-plugin git git-man liberror-perl libslirp0 pigz
  slirp4netns
0 upgraded, 11 newly installed, 0 to remove and 80 not upgraded.
Need to get 106 MB of archives.
After this operation, 404 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

Consider adding the currently logged-in user to the docker group after the command has been completed successfully.
You can use this to run Docker without using the sudo command.

sudo usermod -aG docker $USER
newgrp docker

Step 6: Confirm that Docker is installed

Run the following command to confirm that Docker is set up:

$ docker version

Output,

Client: Docker Engine - Community
 Version:           20.10.21
 API version:       1.41
 Go version:        go1.18.7
 Git commit:        baeda1f
 Built:             Tue Oct 25 18:01:58 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.21
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.18.7
  Git commit:       3056208
  Built:            Tue Oct 25 17:59:49 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.9
  GitCommit:        1c90a442489720eec95342e1789ee8a5e1b9536f
 runc:
  Version:          1.1.4
  GitCommit:        v1.1.4-0-g5fd4c4d
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Step 7: Verify Docker Status

Now, use the “systemctl” command listed below to see if Docker is now operating on your system:

sudo systemctl start docker
sudo systemctl  enable docker
sudo systemctl status docker

Output,

docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2022-11-04 11:34:11 EAT; 4min 0s ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 5879 (dockerd)
      Tasks: 8
     Memory: 25.3M
        CPU: 616ms
     CGroup: /system.slice/docker.service
             └─5879 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Nov 04 11:34:01 ezrah-VirtualBox dockerd[5879]: time="2022-11-04T11:34:01.319799306+03:00" level=info msg="scheme \"unix\" not regi>

Step 8: How to use Docker on Ubuntu 22.04|20.0418.04

You can use Docker after setting it up on Ubuntu 22.04|20.04|18.04 to download and run any test container.
For instance, the “hello-world” Docker test container can be downloaded by doing the following:

docker run hello-world

Output,

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete 
Digest: sha256:e18f0a777aefabe047a671ab3ec3eed05414477c951ab1a6f352a06974245fe7
Status: Downloaded newer image for hello-world:latest

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/

Run the following command to verify the images on the system:

docker images

Output,

REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
hello-world   latest    feb5d9fea6a5   13 months ago   13.3kB

Then, run the “docker ps” command while using the “-a” flag to see details about any active Docker containers:

sudo docker ps -a

You can see that the “hello-world” container has been added successfully in the output presented below.

Output:

CONTAINER ID   IMAGE         COMMAND    CREATED         STATUS                     PORTS     NAMES
301748db3109   hello-world   "/hello"   2 minutes ago   Exited (0) 2 minutes ago             sweet_heisenberg

Conclusion

This concludes our guide on How to Install Docker CE on Ubuntu 22.04|20.04|18.04 in this tutorial.

Read more about Docker.

Other interesting guides:

- Advertisment -

Recent posts

LEAVE A REPLY

Please enter your comment!
Please enter your name here