ps:讲真的学到这应该不用讲网络配置了
1.docker安装
cd /etc/yum.repos.d
mkdir bak
mv *repo bak
1.1配置镜像源
备份老的yum文件
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
配置阿里云镜像
systemctl disable firewalld
systemctl stop firewalld
关闭防火墙
curl -o /etc/yum.repos.d/Centos-7.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/docker-ce.repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
添加阿里云docker镜像源
yum clean all && yum makecache
清理样源缓存
yum install docker-ce -y
下载最新的
#yum list docker-ce --showduplicates | sort -r
如有需要可以查看docker版本安装老的
2.配置docker加速器
touch /etc/docker/daemon.json
{
"registry-mirrors" : ["https://docker.registry.cyou",
"https://docker.1panel.live",
"https://docker.1ms.run",
"https://docker-cf.registry.cyou",
"https://dockercf.jsdelivr.fyi",
"https://docker.jsdelivr.fyi",
"https://dockertest.jsdelivr.fyi",
"https://mirror.aliyuncs.com",
"https://dockerproxy.com",
"https://mirror.baidubce.com",
"https://docker.m.daocloud.io",
"https://docker.nju.edu.cn",
"https://docker.mirrors.sjtug.sjtu.edu.cn",
"https://docker.mirrors.ustc.edu.cn",
"https://mirror.iscas.ac.cn",
"https://docker.rainbond.cc",
"https://do.nark.eu.org",
"https://dc.j8.work",
"https://dockerproxy.com",
"https://gst6rzl9.mirror.aliyuncs.com",
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com",
"http://mirrors.ustc.edu.cn/",
"https://mirrors.tuna.tsinghua.edu.cn/",
"http://mirrors.sohu.com/"
],
"insecure-registries" : [
"registry.docker-cn.com",
"docker.mirrors.ustc.edu.cn"
],
"debug": true,
"experimental": false
}
#阿里云的加速无法使用,这个是由之前看到的前辈整理以及自己添加几个的加速器
#可以拉取镜像,但是不能搜索(悲
#如有需要还是建议整个VPN
systemctl enable docker
systemctl daemon-reloadsystemctl restart docker
这样就可以正常使用了
ps:如果有报错那大概率是加速器问题,检查代码是否有误,已经逗号是否正常添加
如果docker info查看加速器是否正常底下有这样子(没有成功挂上加速器
WARNING: bridge-nf-call-编辑iptables is disabled WARNING: bridge-nf-call-ip6tables is disabled
直接把这段代码复制给deepseek 开启这个就行
3.ps:批量拉取镜像小文件(附加)
cat <<EOF > images.txt
nginx
tomcat
centos:7.8
centos
ubuntu
redis:7.2
EOF
image文件里可以添加你要的镜像以及版本号
#!/bin/bash
while read -r image; do
echo "正在拉取: $image"
docker pull $image
done < images.txt
chmod +x pull_images.sh
./pull_images.sh
再执行这两个命令就可以运行了