0
点赞
收藏
分享

微信扫一扫

docker搭建本地私有仓库详细步骤

看山远兮 2022-07-27 阅读 72

文章目录

1、首先下载 registry 镜像

```html/xml
docker pull registry


![image.png](https://s2.51cto.com/images/20220718/1658151817592903.png?x-oss-process=image/watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_30,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=)
### 2、在 daemon.json 文件中添加私有镜像仓库的地址并重启
```html/xml
vim /etc/docker/daemon.json
{ 
  "insecure-registries": ["192.168.74.74:5000"], #添加此段,“,”不可少,ip是本机IP地址
  "registry-mirrors": ["https://4abdkxlk.mirror.aliyuncs.com"]
}

systemctl daemon-reload
systemctl restart docker.service

image.png
image.png

3、创建registry容器并开放端口

```html/xml
docker create -it registry /bin/bash
docker run -d -p 5000:5000 -v /data/registry:/tmp/registry registry
'//-p指定端口,一内一外;-v表示挂载,前者是宿主机,后者是容器'


![image.png](https://s2.51cto.com/images/20220718/1658152352361481.png?x-oss-process=image/watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_30,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=)
![image.png](https://s2.51cto.com/images/20220718/1658152396713403.png?x-oss-process=image/watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_30,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=)
### 4、给镜像打标签后上传到私有仓库
```html/xml
#打标签
docker tag nginx:v2 192.168.74.74:5000/nginx
#上传
docker push 192.168.74.74:5000/nginx

image.png
image.png
image.png

5、获取私有仓库列表查看是否上传成功

curl -XGET http://192.168.74.74:5000/v2/_catalog

'//若成功会返回以下值'
{"repositories":["nginx"]}

6、验证:从私有仓库下载镜像

#删除原有镜像
 docker rmi 192.168.74.74:5000/nginx
#查看镜像
docker images 
#从本地仓库下载镜像
docker pull 192.168.74.74:5000/nginx
#查看镜像
docker images 

image.png
image.png
tomcat上传仓库
image.png
image.png

总结

怎么获取registry的镜像仓库中的镜像信息

curl -XGET http://192.168.59.111:5000/v2/_catalog
举报

相关推荐

0 条评论