In this tutorial, I am going to begin by focusing on Docker. I am just going to answer the simple question: What is Docker? So primarily Docker is a container runtime. A container runtime is simply a piece of software that actually allows you to implement and run containers. Container is not a specific tool or technology. There are actually multiple different container runtimes and technologies. Containers are really just a concept, and Docker is one of these specific tools that allow you to implement that concept and in fact, Docker is currently the most popular container runtime. So if you want to actually run containers, Docker is a great tool that can allow you to do so. So Docker allows you to run containers on systems and it also offers a variety of other tools in support of that container technology. For example, it allows you to build and manage containers as well as build and manage container images. So it’s just kind of a suite of different tools that brings together a lot of features and functionality that ultimately allows you to create, manage, and run your containers. If you want more information about Docker, be sure to check out the official Docker site for their full documentation and plenty of additional information about Docker. You can find that at www.docker.com. Let’s start the docker installation steps on the Linux based server.
Prerequisites
$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2 $ 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 $ sudo yum install http://mirror.centos.org/centos/7/extras/x86_64/Packages/container-selinux-2.107-3.el7.noarch.rpm
Install Docker
$ sudo yum install docker-ce ------------------------------------ Total 97 MB/s | 88 MB 00:00:00 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
Enable Docker Service
$ sudo systemctl enable docker Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
Start Docker Service
$ sudo systemctl start docker
$ sudo systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2020-09-03 21:15:00 UTC; 2s ago
Docs: https://docs.docker.com
Main PID: 3907 (dockerd)
Tasks: 10
Memory: 42.9M
CGroup: /system.slice/docker.service
└─3907 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Verify Docker
$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete
Digest: sha256:7f0a9f93b4aa3022c3a4c147a449bf11e0941a1fd0bf4a8e6c9408b2600777c5
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/
Adding User to Docker group so that User can run commands without SUDO command.
$ sudo usermod -a -G docker cloud_user $ id cloud_user uid=1002(cloud_user) gid=1003(cloud_user) groups=1003(cloud_user),10(wheel),987(docker)
Conclusion
Basically, that’s all you need to know about Docker installation on CentOS. There are more tutorials that will go into deeper explanation of using Docker thoroughly, but this is a simple article to just get familiar with the setup of Docker.