cenos7 docker installation

uninstall old version

Older versions of Docker were called docker or docker-engine. If these programs are installed, uninstall them and their associated dependencies.

$ sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

 

Install Docker Engine-Community

Install using Docker repository

Before installing Docker Engine-Community for the first time on a new host, you need to set up a Docker repository. After that, you can install and update Docker from the repository.

Set up warehouse

Install the required packages. yum-utils provides yum-config-manager, and the device mapper storage driver requires device-mapper-persistent-data and lvm2.

$ sudo yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2

Use the following commands to set up a stable Docker repository (used when downloading images).

Ali Cloud:

$ sudo yum-config-manager \
    --add-repo \
    http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

Install Docker Engine-Community

Install the latest version of Docker Engine-Community and containerd, or go to the next step to install a specific version:

$ sudo yum install docker-ce docker-ce-cli containerd.io

 Docker is not started by default after installation, you need to start it manually, and the docker user group has been created, but there are no users under this user group.

$ sudo systemctl start docker

Then use: docker info command to verify whether the startup is successful.

Sometimes we will find that the domain name of the above mirror address has expired or the domestic link is slow, we can use the following solution:

In China, it is sometimes difficult to pull images from DockerHub. In this case, you can configure an image accelerator. Docker official and many domestic cloud service providers provide domestic accelerator services, such as:

  • HKUST mirror: https://docker.mirrors.ustc.edu.cn/
  • Netease: https://hub-mirror.c.163.com/
  • Alibaba Cloud: https://<your ID>.mirror.aliyuncs.com
  • Qiniu Cloud Accelerator: https://reg-mirror.qiniu.com

After configuring a certain accelerator address, if you find that the image cannot be pulled, please switch to another accelerator address. All major cloud service providers in China provide Docker image acceleration services. It is recommended to select the corresponding image acceleration service according to the cloud platform running Docker.

Aliyun mirror acquisition address: https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors , after logging in, select Mirror Accelerator on the left menu to see your exclusive address:

The above is the screenshot after I log in with my personal Alipay, pay attention to the red circle part, and then configure the mirror address (note that the system I use here is Centos7):

For systems using systemd (Centos6.4 and above), please write the following content in /etc/docker/daemon.json (if the file does not exist, please create this file: vim daemon.json): 

{"registry-mirrors":["https://reg-mirror.qiniu.com/"]}

 After that restart the service:

$ sudo systemctl daemon-reload
$ sudo systemctl restart docker

 

Check whether the accelerator is in effect

Check whether the accelerator is effective After configuring the accelerator, if pulling the image is still very slow, please manually check whether the accelerator configuration is effective, and execute docker info on the command line. If you see the following content from the result, the configuration is successful.

 

Guess you like

Origin blog.csdn.net/qq_25062671/article/details/120964026
Recommended