centos8 安装docker
第一步:关闭防火墙和selinux
#关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
# 关闭 SeLinux
setenforce 0
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
第二步:进入阿里云镜像找到最新版本的镜像进行安装
https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/edge/Packages/
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
yum install -y https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/edge/Packages/docker-ce-19.03.9-3.el7.x86_64.rpm
yum install -y https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/edge/Packages/docker-ce-cli-19.03.9-3.el7.x86_64.rpm
第三步:镜像加速
cat > /etc/docker/daemon.json <<EOF
{
"registry-mirrors":[
"https://kfwkfulq.mirror.aliyuncs.com",
"https://2lqq34jg.mirror.aliyuncs.com",
"https://pee6w651.mirror.aliyuncs.com",
"http://hub-mirror.c.163.com",
"https://docker.mirrors.ustc.edu.cn",
"https://registry.docker-cn.com"
]
}
EOF
第四步:固定IP
docker network create --subnet=172.18.0.0/16 mynetwork
docker run -itd --name test --net mynetwork --ip 172.18.0.2 centos:7 /bin/bash