Docker安装 加加速器配置

该文章已生成可运行项目,

ps:讲真的学到这应该不用讲网络配置了

1.docker安装 

1.1配置镜像源

备份老的yum文件

cd /etc/yum.repos.d

mkdir bak

mv *repo bak

配置阿里云基础镜像源

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

添加阿里云docker镜像源

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

清理样源缓存

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

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

本文章已经生成可运行项目
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值