How to install Docker-ce on Ubuntu 21.10

Docker-ce is a set of platform as a service product that uses OS-level virtualization to deliver software in packages called containers. Containers are usually isolated from one another and bundled their own software libraries and configuration files, they can communicate with each other through well-defined channels.

In this tutorial am going to show you how you can install Docker-ce on Ubuntu 21.10.

Docker makes it possible to get more apps running on the same old servers and also makes it easy to package and ship programs.

Prerequisites

  • Make sure you have user with sudo privileges
  • Have Ubuntu 21.10 server up and running
  • Have basic kwoledge about running commands on a terminal

Table of Contents

  1. Run system updates
  2. Uninstall old docker version
  3. Install Docker Engine
  4. Enable Docker Engine
  5. Start Docker
  6. Check Docker status
  7. Test Docker
  8. Conclusion

1. Run system updates

We need to install recent updates into our system repositories. To do that you need to use the following command in our terminal.

$ sudo apt update && apt upgrade -y

2. Uninstall old Docker versions

If you have ever installed Docker before you need to uninstall them to allow the new Docker-ce to be installed. To do uninstallation, run the following command in your terminal.

$ sudo apt remove docker
Reading package lists... DoneBuilding dependency tree... DoneReading state information... Done
Package 'docker' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

3. Install Docker-ce

To begin installing docker-ce, run the following command on your terminal. It will install docker with its dependencies.

$ sudo apt install docker.io

You will get the following sample output on your terminal.

Sample output
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  bridge-utils containerd dns-root-data dnsmasq-base pigz runc ubuntu-fan
Suggested packages:
  ifupdown aufs-tools cgroupfs-mount | cgroup-lite debootstrap docker-doc rinse zfs-fuse | zfsutils
The following NEW packages will be installed:
  bridge-utils containerd dns-root-data dnsmasq-base docker.io pigz runc ubuntu-fan
0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
Need to get 72.8 MB of archives.
After this operation, 326 MB of additional disk space will be used.
Do you want to continue? [Y/n] 

Press Y to allow installation to continue.

Check the version of docker installed with the following command.

$ docker --version
Docker version 20.10.7, build 20.10.7-0ubuntu5.1

4. Enable Docker-ce

We need to enable docker-ce to start on reboot, in order to avoid starting every time you boot your machine.

$ sudo systemctl enable docker

5. Start Docker-ce service

You are supposed to start the docker service to run containerd environment. To start, use the following command.

$ sudo systemctl start docker

Lastly, we can check the status of docker to see if it is running.

6. Check status of Docker-ce

Check if Docker is running with the following command on your terminal.

$ sudo systemctl status docker

If you got status active, then your docker service is running as expected, if not probably you haven’t started the service.

Output
● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2021-11-27 14:55:28 UTC; 17min ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 10660 (dockerd)
      Tasks: 8
     Memory: 50.8M
        CPU: 601ms
     CGroup: /system.slice/docker.service
             └─10660 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Nov 27 14:55:28 ubuntu dockerd[10660]: time="2021-11-27T14:55:28.434605109Z" level=info msg="scheme \"unix\" not>
Nov 27 14:55:28 ubuntu dockerd[10660]: time="2021-11-27T14:55:28.434914963Z" level=info msg="ccResolverWrapper: >
Nov 27 14:55:28 ubuntu dockerd[10660]: time="2021-11-27T14:55:28.435531943Z" level=info msg="ClientConn switchin>
Nov 27 14:55:28 ubuntu dockerd[10660]: time="2021-11-27T14:55:28.494687714Z" level=info msg="Loading containers:>
Nov 27 14:55:28 ubuntu dockerd[10660]: time="2021-11-27T14:55:28.736014824Z" level=info msg="Default bridge (doc>
Nov 27 14:55:28 ubuntu dockerd[10660]: time="2021-11-27T14:55:28.864815891Z" level=info msg="Loading containers:>
Nov 27 14:55:28 ubuntu dockerd[10660]: time="2021-11-27T14:55:28.937813828Z" level=info msg="Docker daemon" comm>
Nov 27 14:55:28 ubuntu dockerd[10660]: time="2021-11-27T14:55:28.938397056Z" level=info msg="Daemon has complete>
Nov 27 14:55:28 ubuntu systemd[1]: Started Docker Application Container Engine.
Nov 27 14:55:29 ubuntu dockerd[10660]: time="2021-11-27T14:55:29.017010584Z" level=info msg="API listen on /run/>

This one of mine is running as expected.

7. Test Docker-ce

Let’s test our docker to see if it is running. Test using hello-world container.

$ docker run hello-world 
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete 
Digest: sha256:cc15c5b292d8525effc0f89cb299f1804f3a725c8d05e158653a563f15e4f685
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.

Also, test with the following command;

$ docker run -it ubuntu bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
7b1a6ab2e44d: Pull complete 
Digest: sha256:626ffe58f6e7566e00254b638eb7e0f3b11d4da9675088f4781a50ae288f3322
Status: Downloaded newer image for ubuntu:latest

It pulls Ubuntu’s latest version successfully. I can ls to see what is in that container.

$ ls 
bin   dev  home  lib32  libx32  mnt  proc  run   srv  tmp  var
boot  etc  lib   lib64  media   opt  root  sbin  sys  usr

8. Conclusion

From here you can see our Docker-CE is running as expected, Learn other docker commands to be well conversant with docker. Docker Documentation has a tone of information.

About Mason Kipward

I am a technology enthusiast who loves to share gained knowledge through offering daily tips as a way of empowering others. I am fan of Linux and all other things open source.
View all posts by Mason Kipward →

Leave a Reply

Your email address will not be published.