Docker安装 加加速器配置

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-reload

systemctl 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

 再执行这两个命令就可以运行了

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值