コンテナ2:centos 7でdocker環境を導入する


前言
コマンドセットリファレンスアドレス:https://www.runoob.com/docker/centos-docker-install.html
実際の操作
カーネルの準備
#      
$ uname -r
     3.10.0-957.el7.x86_64
#  AUFS      ,          
$ ls -l /sys/class/misc/device-mapper
     lrwxrwxrwx. 1 root root 0 Jun 17 17:57 /sys/class/misc/device-mapper -> ../../devices/virtual/misc/device-mapper
#       Device Mapper,    device-mapper   
$ sudo yum install -y device-mapper
#      dm_mod    
$ sudo modprobe dm_mod

#CentOS7    
#  admin    $ su- 
#yum( Yellow dog Updater, Modified)    Fedora RedHat  SUSE  Shell        
#yum [options] [command] [package ...]
#GCC:GNU Compiler Collection(GUN      ),     C、C++、JAV、Fortran、Pascal、Object-C、Ada   
$ yum -y install gcc
$ yum -y install gcc-c++
yum             ,      ,       


配置のインストール(脱$記号)

#     , yum            ,  
yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-selinux \ docker-engine-selinux \ docker-engine
#     (    )
yum install -y yum-utils device-mapper-persistent-data lvm2
#       (  )
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
 (   ,  )
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo


#yumパッケージインデックスの更新(次はぼやけているので別々に書く)yum makecache fast
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.cqu.edu.cn
 * extras: mirrors.cqu.edu.cn
 * updates: mirrors.cqu.edu.cn
base                                                                              | 3.6 kB  00:00:00     
docker-ce-stable                                                                  | 3.5 kB  00:00:00     
extras                                                                            | 2.9 kB  00:00:00     
updates                                                                           | 2.9 kB  00:00:00     
(1/2): docker-ce-stable/x86_64/updateinfo                                         |   55 B  00:00:02     
(2/2): docker-ce-stable/x86_64/primary_db                                         |  45 kB  00:00:02     
Metadata Cache Created


#1、最新のDocker Engine-Communityをインストールし、yumパッケージインデックスを更新する
sudo yum install docker-ce docker-ce-cli containerd.io


#2、バージョンのインストールを指定:
#               
$ yum list docker-ce --showduplicates | sort -r
#$ sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io

    3:19.03.7-3.el7
yum install docker-ce-3:19.03.7-3.el7 docker-ce-cli-3:19.03.7-3.el7 containerd.io

Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.cqu.edu.cn
 * extras: mirrors.cqu.edu.cn
 * updates: mirrors.cqu.edu.cn
No package docker-ce-3:19.03.7-3.el7 available.
No package docker-ce-cli-3:19.03.7-3.el7 available.
Resolving Dependencies
--> Running transaction check
---> Package containerd.io.x86_64 0:1.2.13-3.2.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: containerd.io-1.2.13-3.2.el7.x86_64
--> Running transaction check
---> Package container-selinux.noarch 2:2.119.1-1.c57a6f9.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=========================================================================================================
 Package                   Arch           Version                         Repository                Size
=========================================================================================================
Installing:
 containerd.io             x86_64         1.2.13-3.2.el7                  docker-ce-stable          25 M
Installing for dependencies:
 container-selinux         noarch         2:2.119.1-1.c57a6f9.el7         extras                    40 kzao

Transaction Summary
=========================================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 25 M
Installed size: 97 M
Is this ok [y/d/N]: 


操作:y続行操作:y
Downloading packages:
(1/2): container-selinux-2.119.1-1.c57a6f9.el7.noarch.rpm                         |  40 kB  00:00:00     
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/containerd.io-1.2.13-3.2.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Public key for containerd.io-1.2.13-3.2.el7.x86_64.rpm is not installed
(2/2): containerd.io-1.2.13-3.2.el7.x86_64.rpm                                    |  25 MB  00:00:59     
---------------------------------------------------------------------------------------------------------
Total                                                                    438 kB/s |  25 MB  00:00:59     
Retrieving key from https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
Importing GPG key 0x621E9F35:
 Userid     : "Docker Release (CE rpm) "
 Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
 From       : https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
....
Installed:
  containerd.io.x86_64 0:1.2.13-3.2.el7                                                                  

Dependency Installed:
  container-selinux.noarch 2:2.119.1-1.c57a6f9.el7                                                       

Complete!


dockerの起動
sudo systemctl start docker
Failed to start docker.service: Unit not found
#  
yum update(    ,     )
yum -y update      ,            
yum -y upgrade       ,          
     (      :shutdown -r now)
       
yum -y install docker-ce
  
  Installed:
      docker-ce.x86_64 3:19.03.12-3.el7                                                                                                                                                                              
  Dependency Installed:
      docker-ce-cli.x86_64 1:19.03.12-3.el7 
   
#     hello-world              Docker Engine-Community 
sudo docker run hello-world
docker version

Hello from Docker! インストール完了