1. Install dependency package
[root@localhost ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
2. Set alicloud image source
[root@localhost ~]# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
3. Installing docker CE
[root@localhost ~]# yum install -y docker-ce
4. Turn off firewall and enhanced security
[root@localhost ~]# systemctl stop firewalld.service [root@localhost ~]# setenforce 0 [root@localhost ~]#
5. Turn on the service and set it to start automatically
[root@localhost ~]# systemctl start docker.service [root@localhost ~]# systemctl enable docker.service Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service. [root@localhost ~]#
6. Set alicloud image acceleration
(1) Enter the alicloud homepage, select login, and you can register one if you don't have an account
(2) Select console after login
(3) Select products and services, then container image services
(4) Select the lowest image accelerator. Then you can provide the corresponding accelerator address according to your system. Everyone has their own accelerator address
(5) Configure image acceleration
[root@localhost ~]# cd /etc/docker/ ##If there is no such directory, you need to create it manually [root@localhost docker]# ls key.json [root@localhost docker]# tee /etc/docker/daemon.json <<-'EOF' ##Configure image acceleration > { > "registry-mirrors": ["https://******.******.aliyuncs.com"] > } > EOF { "registry-mirrors": ["https://******.*******.aliyuncs.com"] } [root@localhost docker]# ls daemon.json key.json [root@localhost docker]# systemctl daemon-reload ##Reload Daemons [root@localhost docker]# systemctl restart docker ##Restart docker [root@localhost docker]#
7. Turn on the packet forwarding function of the system
[root@localhost docker]# echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf [root@localhost docker]# sysctl -p ##load configuration net.ipv4.ip_forward = 1 [root@localhost docker]#