侧边栏壁纸
博主头像
福福不服博主等级

孩子会穿过大雨,去懂人间的道理。

  • 累计撰写 92 篇文章
  • 累计创建 98 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

搭建Docker私有仓库registry

Monster
2024-03-07 / 0 评论 / 3 点赞 / 47 阅读 / 4057 字 / 正在检测是否收录...
温馨提示:
请确保在评论和互动中保持礼貌和尊重。避免使用侮辱性、歧视性或攻击性语言。我们鼓励建设性的讨论和意见交流。

下载registry

拉取镜像,不指定版本默认拉取最新版本镜像。

docker pull registry
Using default tag: latest
latest: Pulling from library/registry
79e9f2f55bf5: Pull complete 
0d96da54f60b: Pull complete 
5b27040df4a2: Pull complete 
e2ead8259a04: Pull complete 
3790aef225b9: Pull complete 
Digest: sha256:169211e20e2f2d5d115674681eb79d21a217b296b43374b8e39f97fcf866b375
Status: Downloaded newer image for registry:latest
docker.io/library/registry:latest

当前最新版本2.8.3

运行registry

后台运行,重启机器自启,数据挂在宿主机/data/registry目录。

docker run -d -v /data/registry:/var/lib/registry --restart always -p 5000:5000 --name registry registry

通过浏览器访问私有仓库,现在仓库里面没有镜像,列表是空的。

http://192.168.170.111:5000/v2/_catalog

推送镜像

本机打标签推送到私有仓库里

docker tag shuai:v1.0.0 127.0.0.1:5000/shuaibi:1.0
docker push 127.0.0.1:5000/shuaibi:1.0
The push refers to repository [127.0.0.1:5000/shuaibi]
5f70bf18a086: Pushed 
556d07333536: Pushed 
50ecdabc71b7: Pushed 
3e9cda2eceec: Pushed 
bb7b60f93aea: Pushed 
0ef3d186e2bd: Pushed 
1e0931f30489: Pushed 
fd97e4a10f39: Pushed 
1.0: digest: sha256:985ee1ebf7ee1146a1ba0ba7e58a23c3deab2d3c36b1b7c8c128f959884f2060 size: 3034

这时再回到浏览器刷新

其它机器推送到私有仓库

在其它机器上编辑daemon.json文件,没有可以就创建

vi /etc/docker/daemon.json 

添加以下信息

{
  "insecure-registries":["192.168.170.111:5000"]
}

如果有DNS服务器,可以将私有仓库解析个域名这里直接指定域名

{
  "insecure-registries":["hub.monster.com:5000"]
}

接着加载daemon文件,重启docker

systemctl daemon-reload
systemctl restart docker

推送镜像到私有仓库去

[root@ceshi ~]# docker tag dengchuanfu/chatgpt-next-web:latest hub.monster.com:5000/chatgpt:1.0
[root@ceshi ~]# docker push hub.monster.com:5000/chatgpt:1.0
The push refers to repository [hub.monster.com:5000/chatgpt]
29117c2678df: Pushed 
82c0fd5deac1: Pushed 
b47a34ba73cb: Pushed 
07b965bc2aca: Pushed 
a2c7e2a1b1ae: Pushed 
63caa1dbfd24: Pushed 
879b1e560390: Pushed 
54e2f0467614: Pushed 
a0bbbabe7b80: Pushed 
78a822fe2a2d: Pushed 
1.0: digest: sha256:ece1b3edb2459e71cdfefaf28a04ef6719ad64f6e170f7ab69f4bd5a96b60089 size: 2420

请求一下私有仓库,可以看到列表多了个chatgpt

[root@ceshi ~]# curl -XGET http://hub.monster.com:5000/v2/_catalog
{"repositories":["chatgpt","shuaibi"]}
[root@ceshi ~]# 

想查看镜像的版本号,可以如下请求查看,刚才我又上传了个1.1

[root@ceshi ~]# curl -XGET http://hub.monster.com:5000/v2/chatgpt/tags/list
{"name":"chatgpt","tags":["1.0","1.1"]}
[root@ceshi ~]# 

从私有仓库下载镜像

和公用仓库拉取镜像一样,在需要的镜像前面加上私有仓库地址即可(前提私有仓库有你要的镜像)

[root@ceshi ~]# docker pull hub.monster.com:5000/chatgpt:1.1
1.1: Pulling from chatgpt
31e352740f53: Pull complete 
560412e561fb: Pull complete 
02735cb6c78b: Pull complete 
86d562f7b855: Pull complete 
0ac51c29bd01: Pull complete 
733720269b1c: Pull complete 
7f983cedea54: Pull complete 
1c1dd01b23b4: Pull complete 
99f0f19a7b2a: Pull complete 
7bf308fea1b9: Pull complete 
Digest: sha256:ece1b3edb2459e71cdfefaf28a04ef6719ad64f6e170f7ab69f4bd5a96b60089
Status: Downloaded newer image for hub.monster.com:5000/chatgpt:1.1
hub.monster.com:5000/chatgpt:1.1

3
  1. 支付宝打赏

    qrcode alipay
  2. 微信打赏

    qrcode weixin
  3. QQ打赏

    qrcode qq

评论区