centos7 installs Docker and changes Alibaba source to download to solve the slow downloading problem of Docker image

Keywords: Docker yum Linux JSON

I. installing Docker

  1. Update yum package to the latest.
    [root@localhost ~]# yum update
    
  2. Install the required software package. Yum util provides the function of Yum config manager. The other two are dependent on the device mapper driver.
     yum install -y yum-utils device-mapper-persistent-data lvm2
    
  3. Set yum source
    yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    
  4. View all docker versions in all warehouses and select a specific version to install
    yum list docker-ce --showduplicates | sort -r
    
  5. Install Docker, command: Yum install Docker CE version number, I selected 18.06.3.ce, as follows
    yum install docker-ce-18.06.3.ce
    
  6. Start Docker, command: systemctl start docker, and then add the startup command, as follows
    [root@localhost ~]# systemctl start docker
    [root@localhost ~]# systemctl enable docker
    
  7. Verify whether the installation is successful (two parts, client and service, indicate that the installation and startup of docker are successful)
    [root@localhost ~]# docker version 
    Client:
     Version:    18.06.3-ce
     API version:    1.35
     Go version:    go1.9.4
     Git commit:    7390fc6
     Built:    Tue Feb 27 22:15:20 2018
     OS/Arch:    linux/amd64
    
    Server:
     Engine:
      Version:    18.06.3-ce
      API version:    1.35 (minimum version 1.12)
      Go version:    go1.9.4
      Git commit:    7390fc6
      Built:    Tue Feb 27 22:17:54 2018
      OS/Arch:    linux/amd64
      Experimental:    false
    

2. Modify the download image source to alicloud

1. Configure accelerator

For example, to configure the alicloud accelerator, first log in to alicloud (please register first if there is no account) and search the container image service.
Path: image center image accelerator accelerator address, accelerator address example: HTTPS: / xxxxx.mirror.aliyuncs.com

2. Use the accelerator by modifying the daemon configuration file / etc/docker/daemon.json

tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://xxxxxxxx.mirror.aliyuncs.com"]
}
EOF
# Restart Docker
systemctl daemon-reload
systemctl restart docker

3. Verify success

docker info
# Output is as follows
Containers: 38
 Running: 18
 Paused: 0
 Stopped: 20
Images: 10
Server Version: 18.06.3
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: bb71b10fd8f58240ca47fbb579b9d1028eea7c84
runc version: 2b18fe1d885ee5083ef9f0838fee39b62d653e30
init version: fec3683
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.15.0-51-generic
Operating System: Ubuntu 18.04.2 LTS
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.924GiB
Name: kubernetes-master
ID: PJ4H:7AF2:P5UT:6FMR:W4DI:SSWR:IQQR:J6QO:ARES:BOAC:ZVMO:SV2Y
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
## Here is your image accelerator
Registry Mirrors:
 https://xxxxxxxx.mirror.aliyuncs.com/
Live Restore Enabled: false
Product License: Community Engine
WARNING: No swap limit support

If Registry Mirrors is the alicloud image address you have configured, it means that you have successfully configured it.
At this point, Docker has completed the installation and configuration of Alibaba cloud image accelerator.

Posted by andrew6607 on Sat, 26 Oct 2019 07:05:27 -0700