How Install Docker on CentOS 7

Docker Overview

Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications. By taking advantage of Docker’s methodologies for shipping, testing, and deploying code quickly, you can significantly reduce the delay between writing code and running it in production.

Docker Architecture

Docker Installation

Ensure all packages is latest updated

[root@panel ~]# yum check-update
[root@panel ~]# curl -fsSL https://get.docker.com/ | sh
# Executing docker install script, commit: 93d2499759296ac1f9c510605fef85052a2c32be
+ sh -c 'yum install -y -q yum-utils'
Failed to set locale, defaulting to C
+ sh -c '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
+ '[' stable '!=' stable ']'
+ sh -c 'yum makecache'
....
Metadata Cache Created
+ '[' -n '' ']'
+ sh -c 'yum install -y -q docker-ce'
Failed to set locale, defaulting to C
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/containerd.io-1.4.12-3.1.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Public key for containerd.io-1.4.12-3.1.el7.x86_64.rpm is not installed
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
setsebool:  SELinux is disabled.
+ version_gte 20.10
+ '[' -z '' ']'
+ return 0
+ sh -c 'yum install -y -q docker-ce-rootless-extras'
Package docker-ce-rootless-extras-20.10.12-3.el7.x86_64 already installed and latest version
================================================================================
To run Docker as a non-privileged user, consider setting up the
Docker daemon in rootless mode for your user:

    dockerd-rootless-setuptool.sh install

Visit https://docs.docker.com/go/rootless/ to learn about rootless mode.

To run the Docker daemon as a fully privileged service, but granting non-root
users access, refer to https://docs.docker.com/go/daemon-access/

WARNING: Access to the remote API on a privileged Docker daemon is equivalent
         to root access on the host. Refer to the 'Docker daemon attack surface'
         documentation for details: https://docs.docker.com/go/attack-surface/
================================================================================
[root@panel ~]# systemctl start docker
[root@panel ~]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2022-03-03 07:41:04 EST; 9s ago
     Docs: https://docs.docker.com
 Main PID: 233718 (dockerd)
    Tasks: 24
   Memory: 45.1M
   CGroup: /system.slice/docker.service
           └─233718 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Mar 03 07:41:03 panel dockerd[233718]: time="2022-03-03T07:41:03.631683300-05:00" level=info msg="scheme \"unix\" not registered, fallback to default scheme" module=grpc
Mar 03 07:41:03 panel dockerd[233718]: time="2022-03-03T07:41:03.631757170-05:00" level=info msg="ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.soc..." module=grpc
Mar 03 07:41:03 panel dockerd[233718]: time="2022-03-03T07:41:03.631808468-05:00" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc
Mar 03 07:41:03 panel dockerd[233718]: time="2022-03-03T07:41:03.823563078-05:00" level=info msg="Loading containers: start."
Mar 03 07:41:04 panel dockerd[233718]: time="2022-03-03T07:41:04.108837913-05:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon opt...d IP address"
Mar 03 07:41:04 panel dockerd[233718]: time="2022-03-03T07:41:04.276840866-05:00" level=info msg="Loading containers: done."
Mar 03 07:41:04 panel dockerd[233718]: time="2022-03-03T07:41:04.340709321-05:00" level=info msg="Docker daemon" commit=459d0df graphdriver(s)=overlay2 version=20.10.12
Mar 03 07:41:04 panel dockerd[233718]: time="2022-03-03T07:41:04.340947718-05:00" level=info msg="Daemon has completed initialization"
Mar 03 07:41:04 panel systemd[1]: Started Docker Application Container Engine.
Mar 03 07:41:04 panel dockerd[233718]: time="2022-03-03T07:41:04.480331589-05:00" level=info msg="API listen on /var/run/docker.sock"
Hint: Some lines were ellipsized, use -l to show in full.
[root@panel ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@panel ~]# useradd kiwil
[root@panel ~]# usermod -aG docker kiwil
[root@panel ~]# newgrp docker 
[root@panel ~]# su - kiwil
[kanwil@panel ~]$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete 
Digest: sha256:97a379f4f88575512824f3b352bc03cd75e239179eea0fecc38e597b2209f49a
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/