Install docker-ce in VM using yum

Posted by copernic67 on Sat, 15 Feb 2020 05:49:42 +0100

WeChat Public Number: WELTest

Preconditions

Dependent Software

VM PRO
Link: https://pan.baidu.com/s/1yRUIVKFqDwQyoOk9oJvu7g 
Extraction Code: rgl2
Centos7 ISO[CentOS-7-x86_64-Minimal-1611.iso]
Link: https://pan.baidu.com/s/10cgmjK7qtpc3DGCD67YmgA 
Extraction Code: fzmr 
Xshell
Link: https://pan.baidu.com/s/1WuUpZwRbK1Y38rp2mzsU9w 
Extraction Code: w9lf 

Configuration Related

Depending on the software provided, Centos7's virtual machine is built with VM, and many commands are not provided because the mirroring provided is to minimize mirroring.Here are some dependent configurations.

Static IP Configuration:

Sample Profile Content

TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=7820b169-8f18-4ca4-8478-cd0a4fc8d0ca
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.153.88
NETMASK=255.255.255.0
GATEWAY=192.168.153.2
DNS1=114.114.114.114
DNS2=8.8.8.8

Yum source configuration:

Here is the yum source Baidu cloud link I use:

Link: https://pan.baidu.com/s/1s9obKtjA3mixJcSpEovgLQ 
Extraction Code: i6he 

install

First IP Settings

Because it is a minimal installation, after installation, you need to set up static IP and DNS configurations to connect to the external network before you can connect through the xshell script.

Execute the edit command:

vi /etc/sysconfig/network-scripts/ifcfg-ens33

Adjustments need to be made referring to the Static IP Configuration sample. If you want to copy and paste, you need to comment out the UUID field, otherwise the service will not come up.

After editing, restart the network service by executing the following command:

systemctl restart network

Execute the following command to verify that the IP is set correctly, and you will see the corresponding IP if it is set successfully:

ip a

Second configuration yum

Connecting a virtual machine through an xshell is not detailed here.

The connection successfully executed the following command to close the firewall:

sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
systemctl stop firewalld.service && systemctl disable firewalld.service

Enter the / etc/yum.repos.d directory to execute the following commands:

cd /etc/yum.repos.d && rm -rf *

Then put the two files in ** "Yum Source Configuration"** in the / etc/yum.repos.d directory.How to put it here in no detail, if you don't understand, you can trust me privately.

The following files appear at/etc/yum.repos.d:

[root@weltest yum.repos.d]# ll
//Total usage 8
-rw-r--r--. 1 root root 1616 2 June 10:23 CentOS-Base.repo
-rw-r--r--. 1 root root 2640 2 June 10:23 docker-ce.repo

Then execute the following command:

[root@weltest yum.repos.d]# yum clean all
//Plugin loaded: fastestmirror
//Cleaning up software source: base docker-ce-stable extras updates
Cleaning up everything
Cleaning up list of fastest mirrors
[root@weltest yum.repos.d]# yum makecache
//Plugin loaded: fastestmirror
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/14): base/7/x86_64/group_gz                                                                                                             | 165 kB  00:00:03     
(2/14): base/7/x86_64/filelists_db                                                                                                         | 7.3 MB  00:00:09     
(3/14): base/7/x86_64/primary_db                                                                                                           | 6.0 MB  00:00:06     
(4/14): docker-ce-stable/x86_64/filelists_db                                                                                               |  18 kB  00:00:02     
(5/14): docker-ce-stable/x86_64/updateinfo                                                                                                 |   55 B  00:00:02     
(6/14): base/7/x86_64/other_db                                                                                                             | 2.6 MB  00:00:02     
(7/14): docker-ce-stable/x86_64/primary_db                                                                                                 |  38 kB  00:00:00     
(8/14): extras/7/x86_64/filelists_db                                                                                                       | 210 kB  00:00:00     
(9/14): docker-ce-stable/x86_64/other_db                                                                                                   | 111 kB  00:00:00     
(10/14): extras/7/x86_64/primary_db                                                                                                        | 159 kB  00:00:00     
(11/14): extras/7/x86_64/other_db                                                                                                          | 103 kB  00:00:00     
(12/14): updates/7/x86_64/filelists_db                                                                                                     | 4.0 MB  00:00:03     
(13/14): updates/7/x86_64/other_db                                                                                                         | 481 kB  00:00:00     
(14/14): updates/7/x86_64/primary_db                                                                                                       | 6.7 MB  00:00:05     
Determining fastest mirrors
//Metadata cache established
[root@weltest yum.repos.d]# 

Third install docker-ce via Yum

There are no errors in the first IP setting and the second configuration yum.Install the basic software:

yum install -y net-tools wget lrzsz

After the basic software is installed, you can execute some simple commands: ifconfig, ping, netstat, wget, sz, rz, and so on.

Install docker-ce from the yum source and execute the following commands:

yum install -y docker-ce

After successful installation, execute the command to start the docker:

systemctl start docker

Edit the file: /etc/docker/daemon.json, add the following to the file:

{
"registry-mirrors": ["http://hub-mirror.c.163.com"]
}

Then execute the command to restart the docker:

systemctl stop docker
systemctl reload docker
systemctl start docker

Fourth, verify that docker is installed successfully

Execute the docker pull command to pull the mirror, giving the following examples:

root@weltest yum.repos.d]# docker pull alpine
Using default tag: latest
latest: Pulling from library/alpine
c9b1b535fdd9: Pull complete 
Digest: sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
Status: Downloaded newer image for alpine:latest
docker.io/library/alpine:latest
[root@weltest yum.repos.d]# cd ~
[root@weltest ~]# docker images
REPOSITORY                                                   TAG                 IMAGE ID            CREATED             SIZE
alpine                                                       latest              e7d92cdc71fe        3 weeks ago         5.59MB

        
             ;  

593 original articles published, 221 complimented, 1.3 million visits+
His message board follow

Topics: Docker yum network SELinux