宿主机开启转发。网桥配置完后,需要开启转发,不然容器启动后,就会没有网络,配置/etc/sysctl.conf
,添加net.ipv4.ip_forward=1
vim /etc/sysctl.conf
#配置转发
net.ipv4.ip_forward=1
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
#重启服务,让配置生效
systemctl restart network
#查看是否成功,如果返回为“net.ipv4.ip_forward = 1”则表示成功
sysctl net.ipv4.ip_forward
配置docker-ce的镜像源
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install -y yum-utils device-mapper-persistent-data lvm2
查看可安装的版本
yum list docker-ce --showduplicates | sort -r
yum -y install docker-ce-20.10.9 docker-ce-cli-20.10.9 containerd.io #安装
配置容器引擎。创建国内加速镜像
mkdir /etc/docker
&& vim /etc/docker/daemon.json
{
"graph":"/opt/docker",
"storage-driver":"overlay2",
"storage-opts": [
"overlay2.override_kernel_check=true"
],
"insecure-registries":["registry.access.redhat.com","quay.io"],
"registry-mirrors":[
"https://docker.mirrors.ustc.edu.cn",
"https://hub-mirror.c.163.com","http://f1361db2.m.daocloud.io",
"https://docker.mirrors.ustc.edu.cn"
],
"bip":"172.7.5.1/24",
"exec-opts":["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m",
"max-file": "3"
},
"live-restore": true,
"default-ulimits": {
"nofile" : {
"Name" : "nofile" ,
"Hard" : 64000 ,
"Soft" : 64000
}
}
}
配置参数详解:
- graph: 存储路径
- storage-driver : 存储驱动
- insecure-registries:配置私库地址
- registry-mirrors:配置镜像地址
- bip,配置网络(建议172开头,中间两位为,宿主机的后两位,最后是0或者1,能够快速定位宿主机)
- exec-ops:启动额外参数
- live-restore:容器引擎宕机,容器不宕机
启动docker
systemctl enable docker && systemctl start docker && systemctl status docker #启动
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(0)