Introduction
In this article, we’ll demonstrate how to install Docker on a Centos 7 system. But before we get to that let’s briefly understand what Docker actually is? Docker is a containerization engine and platform that encapsulates application code along with all of its dependencies into a docker container. The docker engine allows containerized applications to run seamlessly irrespective of the underlying operating system (the exception being you can’t run Windows containers on Linux operating systems yet). The concept of containers allows users to provide the same environment to the application in dev, stage and production thereby greatly improving developer productivity and accelerating the application deployment life cycle. We’ll be covering many different aspects of the docker containerization platform like docker hub, docker images, networking, and storage.
Check pre-requisites:
We’ll be installing Docker on a Centos 7 machine and docker has a couple of dependencies which we’ll need to check before we may proceed with the install itself.
[sahil@linuxnix ~]$ cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core) [sahil@linuxnix ~]$ [sahil@linuxnix ~]$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile epel/x86_64/metalink | 18 kB 00:00:00 * base: mirror.aktkn.sg * epel: d2lzkl7pfhq30w.cloudfront.net * extras: mirror.aktkn.sg * nux-dextop: mirror.li.nux.ro * updates: mirror.aktkn.sg base | 3.6 kB 00:00:00 epel | 5.3 kB 00:00:00 extras | 3.4 kB 00:00:00 nux-dextop | 2.9 kB 00:00:00 puppet6 | 2.5 kB 00:00:00 tigervnc-el7 | 2.9 kB 00:00:00 updates | 3.4 kB 00:00:00 xrdp | 2.9 kB 00:00:00 (1/3): epel/x86_64/updateinfo | 985 kB 00:00:01 (2/3): updates/7/x86_64/primary_db | 6.5 MB 00:00:00 (3/3): epel/x86_64/primary_db | 6.7 MB 00:00:01 Package yum-utils-1.1.31-50.el7.noarch already installed and latest version Package device-mapper-persistent-data-0.7.3-3.el7.x86_64 already installed and latest version Resolving Dependencies --> Running transaction check ---> Package lvm2.x86_64 7:2.02.180-10.el7_6.7 will be updated ---> Package lvm2.x86_64 7:2.02.180-10.el7_6.8 will be an update --> Processing Dependency: lvm2-libs = 7:2.02.180-10.el7_6.8 for package: 7:lvm2-2.02.180-10.el7_6.8.x86_64 --> Running transaction check ---> Package lvm2-libs.x86_64 7:2.02.180-10.el7_6.7 will be updated ---> Package lvm2-libs.x86_64 7:2.02.180-10.el7_6.8 will be an update --> Processing Dependency: device-mapper-event = 7:1.02.149-10.el7_6.8 for package: 7:lvm2-libs-2.02.180-10.el7_6.8.x86_64 --> Running transaction check ---> Package device-mapper-event.x86_64 7:1.02.149-10.el7_6.7 will be updated ---> Package device-mapper-event.x86_64 7:1.02.149-10.el7_6.8 will be an update --> Processing Dependency: device-mapper-event-libs = 7:1.02.149-10.el7_6.8 for package: 7:device-mapper-event-1.02.149-10.el7_6.8.x86_64 --> Processing Dependency: device-mapper = 7:1.02.149-10.el7_6.8 for package: 7:device-mapper-event-1.02.149-10.el7_6.8.x86_64 --> Running transaction check ---> Package device-mapper.x86_64 7:1.02.149-10.el7_6.7 will be updated --> Processing Dependency: device-mapper = 7:1.02.149-10.el7_6.7 for package: 7:device-mapper-libs-1.02.149-10.el7_6.7.x86_64 ---> Package device-mapper.x86_64 7:1.02.149-10.el7_6.8 will be an update ---> Package device-mapper-event-libs.x86_64 7:1.02.149-10.el7_6.7 will be updated ---> Package device-mapper-event-libs.x86_64 7:1.02.149-10.el7_6.8 will be an update --> Running transaction check ---> Package device-mapper-libs.x86_64 7:1.02.149-10.el7_6.7 will be updated ---> Package device-mapper-libs.x86_64 7:1.02.149-10.el7_6.8 will be an update --> Finished Dependency Resolution Dependencies Resolved =========================================================================================================================================================== Package Arch Version Repository Size =========================================================================================================================================================== Updating: lvm2 x86_64 7:2.02.180-10.el7_6.8 updates 1.3 M Updating for dependencies: device-mapper x86_64 7:1.02.149-10.el7_6.8 updates 293 k device-mapper-event x86_64 7:1.02.149-10.el7_6.8 updates 189 k device-mapper-event-libs x86_64 7:1.02.149-10.el7_6.8 updates 188 k device-mapper-libs x86_64 7:1.02.149-10.el7_6.8 updates 321 k lvm2-libs x86_64 7:2.02.180-10.el7_6.8 updates 1.1 M Transaction Summary =========================================================================================================================================================== Upgrade 1 Package (+5 Dependent packages) Total download size: 3.3 M Downloading packages: Delta RPMs disabled because /usr/bin/applydeltarpm not installed. (1/6): device-mapper-event-1.02.149-10.el7_6.8.x86_64.rpm | 189 kB 00:00:00 (2/6): device-mapper-1.02.149-10.el7_6.8.x86_64.rpm | 293 kB 00:00:00 (3/6): device-mapper-event-libs-1.02.149-10.el7_6.8.x86_64.rpm | 188 kB 00:00:00 (4/6): device-mapper-libs-1.02.149-10.el7_6.8.x86_64.rpm | 321 kB 00:00:00 (5/6): lvm2-2.02.180-10.el7_6.8.x86_64.rpm | 1.3 MB 00:00:00 (6/6): lvm2-libs-2.02.180-10.el7_6.8.x86_64.rpm | 1.1 MB 00:00:00 ----------------------------------------------------------------------------------------------------------------------------------------------------------- Total 5.3 MB/s | 3.3 MB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : 7:device-mapper-1.02.149-10.el7_6.8.x86_64 1/12 Updating : 7:device-mapper-libs-1.02.149-10.el7_6.8.x86_64 2/12 Updating : 7:device-mapper-event-libs-1.02.149-10.el7_6.8.x86_64 3/12 Updating : 7:device-mapper-event-1.02.149-10.el7_6.8.x86_64 4/12 Updating : 7:lvm2-libs-2.02.180-10.el7_6.8.x86_64 5/12 Updating : 7:lvm2-2.02.180-10.el7_6.8.x86_64 6/12 Cleanup : 7:lvm2-2.02.180-10.el7_6.7.x86_64 7/12 Cleanup : 7:lvm2-libs-2.02.180-10.el7_6.7.x86_64 8/12 Cleanup : 7:device-mapper-event-1.02.149-10.el7_6.7.x86_64 9/12 Cleanup : 7:device-mapper-event-libs-1.02.149-10.el7_6.7.x86_64 10/12 Cleanup : 7:device-mapper-1.02.149-10.el7_6.7.x86_64 11/12 Cleanup : 7:device-mapper-libs-1.02.149-10.el7_6.7.x86_64 12/12 Verifying : 7:device-mapper-event-libs-1.02.149-10.el7_6.8.x86_64 1/12 Verifying : 7:device-mapper-libs-1.02.149-10.el7_6.8.x86_64 2/12 Verifying : 7:lvm2-2.02.180-10.el7_6.8.x86_64 3/12 Verifying : 7:lvm2-libs-2.02.180-10.el7_6.8.x86_64 4/12 Verifying : 7:device-mapper-event-1.02.149-10.el7_6.8.x86_64 5/12 Verifying : 7:device-mapper-1.02.149-10.el7_6.8.x86_64 6/12 Verifying : 7:device-mapper-libs-1.02.149-10.el7_6.7.x86_64 7/12 Verifying : 7:device-mapper-event-libs-1.02.149-10.el7_6.7.x86_64 8/12 Verifying : 7:device-mapper-event-1.02.149-10.el7_6.7.x86_64 9/12 Verifying : 7:lvm2-libs-2.02.180-10.el7_6.7.x86_64 10/12 Verifying : 7:lvm2-2.02.180-10.el7_6.7.x86_64 11/12 Verifying : 7:device-mapper-1.02.149-10.el7_6.7.x86_64 12/12 Updated: lvm2.x86_64 7:2.02.180-10.el7_6.8 Dependency Updated: device-mapper.x86_64 7:1.02.149-10.el7_6.8 device-mapper-event.x86_64 7:1.02.149-10.el7_6.8 device-mapper-event-libs.x86_64 7:1.02.149-10.el7_6.8 device-mapper-libs.x86_64 7:1.02.149-10.el7_6.8 lvm2-libs.x86_64 7:2.02.180-10.el7_6.8 Complete! [sahil@linuxnix ~]$
Installing Docker
Installing docker is a failry straightforward process. We just need to add the docker repository onto our server and then run the yum install command followed by docker-ce.
[sahil@linuxnix ~]$ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo Loaded plugins: fastestmirror adding repo from: https://download.docker.com/linux/centos/docker-ce.repo grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo repo saved to /etc/yum.repos.d/docker-ce.repo [sahil@linuxnix ~]$ [sahil@linuxnix ~]$ sudo yum install docker-ce Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.aktkn.sg * epel: d2lzkl7pfhq30w.cloudfront.net * extras: mirror.aktkn.sg * nux-dextop: mirror.li.nux.ro * updates: mirror.aktkn.sg docker-ce-stable | 3.5 kB 00:00:00 (1/2): docker-ce-stable/x86_64/primary_db | 29 kB 00:00:00 (2/2): docker-ce-stable/x86_64/updateinfo | 55 B 00:00:00 Resolving Dependencies --> Running transaction check ---> Package docker-ce.x86_64 3:18.09.7-3.el7 will be installed --> Processing Dependency: container-selinux >= 2.9 for package: 3:docker-ce-18.09.7-3.el7.x86_64 --> Processing Dependency: containerd.io >= 1.2.2-3 for package: 3:docker-ce-18.09.7-3.el7.x86_64 --> Processing Dependency: docker-ce-cli for package: 3:docker-ce-18.09.7-3.el7.x86_64 --> Running transaction check ---> Package container-selinux.noarch 2:2.99-1.el7_6 will be installed ---> Package containerd.io.x86_64 0:1.2.6-3.3.el7 will be installed ---> Package docker-ce-cli.x86_64 1:18.09.7-3.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved =========================================================================================================================================================== Package Arch Version Repository Size =========================================================================================================================================================== Installing: docker-ce x86_64 3:18.09.7-3.el7 docker-ce-stable 19 M Installing for dependencies: container-selinux noarch 2:2.99-1.el7_6 extras 39 k containerd.io x86_64 1.2.6-3.3.el7 docker-ce-stable 26 M docker-ce-cli x86_64 1:18.09.7-3.el7 docker-ce-stable 14 M Transaction Summary =========================================================================================================================================================== Install 1 Package (+3 Dependent packages) Total download size: 59 M Installed size: 243 M Is this ok [y/d/N]: y Downloading packages: (1/4): container-selinux-2.99-1.el7_6.noarch.rpm | 39 kB 00:00:00 warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-18.09.7-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY3 ETA Public key for docker-ce-18.09.7-3.el7.x86_64.rpm is not installed (2/4): docker-ce-18.09.7-3.el7.x86_64.rpm | 19 MB 00:00:01 (3/4): docker-ce-cli-18.09.7-3.el7.x86_64.rpm | 14 MB 00:00:00 (4/4): containerd.io-1.2.6-3.3.el7.x86_64.rpm | 26 MB 00:00:02 ----------------------------------------------------------------------------------------------------------------------------------------------------------- Total 28 MB/s | 59 MB 00:00:02 Retrieving key from https://download.docker.com/linux/centos/gpg Importing GPG key 0x621E9F35: Userid : "Docker Release (CE rpm) <docker@docker.com>" Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35 From : https://download.docker.com/linux/centos/gpg Is this ok [y/N]: y Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : 2:container-selinux-2.99-1.el7_6.noarch 1/4 Installing : containerd.io-1.2.6-3.3.el7.x86_64 2/4 Installing : 1:docker-ce-cli-18.09.7-3.el7.x86_64 3/4 Installing : 3:docker-ce-18.09.7-3.el7.x86_64 4/4 Verifying : 3:docker-ce-18.09.7-3.el7.x86_64 1/4 Verifying : 1:docker-ce-cli-18.09.7-3.el7.x86_64 2/4 Verifying : containerd.io-1.2.6-3.3.el7.x86_64 3/4 Verifying : 2:container-selinux-2.99-1.el7_6.noarch 4/4 Installed: docker-ce.x86_64 3:18.09.7-3.el7 Dependency Installed: container-selinux.noarch 2:2.99-1.el7_6 containerd.io.x86_64 0:1.2.6-3.3.el7 docker-ce-cli.x86_64 1:18.09.7-3.el7 Complete! [sahil@linuxnix ~]$
We can check the installed version of docker by running the docker –version command as shown below.
[sahil@linuxnix ~]$ docker --version Docker version 18.09.7, build 2d0083d [sahil@linuxnix ~]$
Note: In case you are wondering what the CE means in the docker-ce package that we installed, we’ll just clear that up right now. Docker comes in two editions, the Enterprise Edition (EE) and the Community Edition (CE). The enterprise edition provides some added features over the community edition like vulnerability scanning, signed containers and same-day support.
Conclusion
This concludes our basic introduction to Docker and it’s installation process. In the next post, we’ll run our first Docker container.
Sahil Suri
Latest posts by Sahil Suri (see all)
- Google Cloud basics: Activate Cloud Shell - May 19, 2021
- Create persistent swap partition on Azure Linux VM - May 18, 2021
- DNF, YUM and RPM package manager comparison - May 17, 2021
- Introduction to the aptitude package manager for Ubuntu - March 26, 2021
- zypper package management tool examples for managing packages on SUSE Linux - March 26, 2021