Docker最新镜像加速地址及本地搭建镜像仓库全流程

我找了一周才找到一个新的docker镜像加速地址,具体用到什么时候不详,且用且珍惜。会限速,不过总比无法下载强上很多。话不多说,直接上干货:
首先,下载地址配置:
地址为:

https://docker.m.daocloud.io

安装不说了,下载地址配置如下:

cat > /etc/docker/daemon.json <<EOF
> {"registry-mirrors": ["https://docker.m.daocloud.io"]}
> EOF

然后重启docker

systemctl  daemon-reload 
systemctl  start  docker.service

接下来就可以pull所需的镜像了。

我这里搭建了镜像本地镜像仓库,把所有所需镜像传到自有仓库中,省的下次关闭后,又得找半天。
第一步 pull镜像仓库的镜像

docker run -d -p 5000:5000   --name registry   --restart=always    registry:2

都不是小白,这里就不多说了,由于很久没搭了,所以百度参考了一下,太多废话。我这里把那些没必要的就省略了,直接整吧;

docker  ps

看了下都run起来了。接下来配置私有仓库地址。由于我是本地测试本机,就直接配的回环地址,如果局域网访问,直接改成镜像仓库服务器的IP就行。

{
  "registry-mirrors": [
    "https://docker.m.daocloud.io"
  ],
"insecure-registries": ["172.0.0.1:5000"]
}

在原有的基础上添加 , “insecure-registries”: [“172.0.0.1:5000”]
如图:
在这里插入图片描述

缩进看个人爱好
然后重新加载:

 systemctl  daemon-reload  
 systemctl  start  docker.service

接下来访问验证一下:(我这里一大堆报错后才找到原因,报错信息我写到下边,遇到后避坑):
*

1. docker push 127.0.0.1:5000/myredis:v1.0 The push refers to
repository [127.0.0.1:5000/myredis] An image does not exist locally
with the tag: 127.0.0.1:5000/myredis

2. The push refers to repository [registry:5000/myredis] Get “https://registry:5000/v2/”: dial tcp: lookup registry on
8.8.8.8:53: no such host

3.Job for docker.service failed because the control process exited with error code. See “systemctl status docker.service” and
“journalctl -xe” for details. [root@localhost redis]# systemctl
status docker.service ● docker.service - Docker Application
Container Engine Loaded: loaded
(/usr/lib/systemd/system/docker.service; disabled; vendor preset:
disabled) Active: failed (Result: start-limit) since 一 2024-06-24
15:36:16 CST; 6s ago
Docs: https://docs.docker.com Process: 5026 ExecStart=/usr/bin/dockerd -H fd://
–containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE) Main PID: 5026 (code=exited, status=1/FAILURE)

接下来进入正题(以上是中间报错):

docker login 127.0.0.1:5000

登录访问验证,root及密码登录就显示成功

在这里插入图片描述
接下来是命令集合:从查看到打标签到上传(可间隔执行,也可直接复制执行)我这里是redis为例。

docker   images
docker   tag  redis:latest   127.0.0.1:5000/myredis:latest
docker push 127.0.0.1:5000/myredis:latest
curl -XGET http://127.0.0.1:5000/v2/_catalog?n=1000

如图:
在这里插入图片描述

最后查看,是已经在仓库中有了 {“repositories”:[“myredis”]} 。

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值