docker-搭建docker镜像私服

一、本地搭建

1、拉取registry

 

1
docker pull registry

 

 

 

 

2、运行容器

1
docker run -d -p 5000:5000 --restart=always --name registry -v /opt/registry:/var/lib/registry registry

  

 

 

 

 

 

 

 

 访问http://localhost:5000/v2/_catalog

 

 

 

3、上传镜像

①查看已有镜像

1
docker images

  

 

 

 

②给要上传的镜像打标签

1
docker tag ocelotgatewaydemo_a:latest 192.168.192.139:5000/ocelotgatewaydemo_a:t1

 

③推送镜像

添加docker配置文件daemon.json文件,配置本地服务地址,保存到服务器的/etc/docker/目录下。

1
2
3
{
    "insecure-registries" : [ "192.168.192.139:5000" ]
}

  

 

 

 

1
docker push 192.168.192.139:5000/ocelotgatewaydemo_a:t1

  

 

 

 

 

 

浏览:http://192.168.192.139:5000/v2/_catalog

 

 

 

④拉取镜像

先删除本地镜像

1
2
docker rmi 192.168.192.139:5000/ocelotgatewaydemo_a:t1
docker pull 192.168.192.139:5000/ocelotgatewaydemo_a:t1

  

 

 

 

 

另外程序员都喜欢用Git,如果把Registry私有仓库比作GitLab的话,那么Docker Hub公共仓库就类似于GitHub,这是一个公共的共享的镜像仓库平台,我们可以像在GitHub上随意得clone公共的开源项目一样pull镜像到本地。

 

鸣谢:

https://www.cnblogs.com/roluodev/p/12251479.html

https://www.runoob.com/docker/docker-container-connection.html

https://www.bianchengquan.com/article/606449.html

 

posted @   春光牛牛  阅读(388)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示