Install docker under centos8
-
The kernel of the centos system must be higher than 3.10
command: uname -r to view the centos kernel -
Update the yum package to the latest
command: yum update -
Uninstall the old version (if you have installed the old version, skip this step if you have not installed it before)
command: yum remove docker docker-common docker-selinux docker-engine -
Install the required software packages
Command: yum install -y yum-utils device-mapper-persistent-data lvm2 -
Set yum source
a: default warehouse address
command: yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
b: aliyun warehouse address
command: yum-config- manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -
Install the latest version of Docker
command: yum install docker-ce docker-ce-cli containerd.io -
The above step 6 may report an error that the version of containerd.io is lower. This is because we only need to update the version of containerd.io. Here I update the following version: https://mirrors.aliyun.com/ docker-ce/linux/centos/7/x86_64/edge/Packages/containerd.io-1.2.13-3.2.el7.x86_64.rpm (skip this step if no error is reported), you can install containerd.io
command: yum install -y https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/edge/Packages/containerd.io-1.2.13-3.2.el7.x86_64.rpm
and repeat step 6 above . -
Start Docker and set boot start
command: systemctl start docker
boot self-start command: systemctl enable docker
start/stop/status command: systemctl start/stop/status docker -
Modify the Docker service configuration
vim /usr/lib/systemd/system/docker.service
to join in ExecStart without a carriage return
-H unix:///var/run/docker.sock -H 0.0.0.0:2375
如:
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock -H unix:///var/run/docker.sock -H 0.0.0.0:2375
# -H unix:///var/run/docker.sock : 开启一个对外主机服务,使用 docker.sock 文件管理
# -H 0.0.0.0:2375 : 允许什么客户端 IP 访问当前服务,当前服务对外暴露的端口号是什么。2375是自定义的端口
Then reload
systemctl daemon-reload
systemctl restart docker
Abnormal x509
Error response from daemon: Get https://registry-1.docker.io/v2/: x509: certificate has expired or is not yet valid
solution:
- Synchronize time
vim /etc/chrony.conf Add server 210.72.145.44 iburst server ntp.aliyun.com iburst
at the end - Reload configuration
systemctl restart chronyd.service - Time synchronization
chronyc sources -v - get time
date