#关闭并禁用防火墙
systemctl stop firewalld
systemctl disable firewalld
#停用并禁用selinux
setenforce 0
sed -ri s'#(SELINUX=)enforcing#\1disabled#' /etc/selinux/config
#卸载docker较旧的依赖项
yum -y remove docker*
yum install -y yum-utils
#配置docker的yum地址
sudo yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install -y docker-ce docker-ce-cli containerd.io
#安装指定版本docker和容器运行时
#yum install -y docker-ce-20.10.8 docker-ce-cli-20.10.8 containerd.io-1.4.9
#启动&开机启动docker
systemctl enable docker --now
# docker加速配置
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://jd64xula.mirror.aliyuncs.com"],
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2"
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
sudo systemctl status docker
本文由博客一文多发平台 OpenWrite 发布!