Docker私有仓库
私有仓库搭建
首先启动docker
-
拉取私有仓库镜像
[root@server-a ~]# 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
-
启动私有仓库容器
[root@server-a ~]# docker run -id --name=registry -p 5000:5000 registry
-
打开浏览器,输入地址http://私有仓库服务器 ip:5000/v2/_catalog
-
修改daemon json 追加信息
[root@server-a ~]# vim /etc/docker/daemon.json [root@server-a ~]# cat /etc/docker/daemon.json { "registry-mirrors": ["https://m03eesz2.mirror.aliyuncs.com"], "insecure-registries":["192.168.10.128:5000"] }
-
重启服务
systemctl restart docker
docker start registry
将镜像上传至私有仓库
-
查看镜像
[root@server-a ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE app latest d8cb1b6dcd58 30 hours ago 488MB nginx latest 605c77e624dd 16 months ago 141MB openjdk latest 5f94f53bbced 16 months ago 471MB tomcat latest fb5657adc892 16 months ago 680MB registry latest b8604a3fe854 18 months ago 26.2MB centos 7 eeb6ee3f44bd 20 months ago 204MB
-
将centos7传入仓库,先打上标记
[root@server-a ~]# docker tag centos:7 192.168.10.128:5000/centos:7 [root@server-a ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE app latest d8cb1b6dcd58 30 hours ago 488MB nginx latest 605c77e624dd 16 months ago 141MB openjdk latest 5f94f53bbced 16 months ago 471MB tomcat latest fb5657adc892 16 months ago 680MB registry latest b8604a3fe854 18 months ago 26.2MB 192.168.10.128:5000/centos 7 eeb6ee3f44bd 20 months ago 204MB centos 7 eeb6ee3f44bd 20 months ago 204MB
-
错误
[root@server-a ~]# docker push 192.168.10.128:5000/centos Using default tag: latest The push refers to repository [192.168.10.128:5000/centos] tag does not exist: 192.168.10.128:5000/centos:latest
这段话提示没有此标签,检查了下,这里我的centos后面没有加上版本号7 ,如果你是latest就不用加
-
解决文章来源:https://www.toymoban.com/news/detail-441235.html
[root@server-a ~]# docker push 192.168.10.128:5000/centos:7
The push refers to repository [192.168.10.128:5000/centos]
174f56854903: Pushed
7: digest: sha256:dead07b4d8ed7e29e98de0f4504d87e8880d4347859d839686a31da35a3b532f size: 529
- 访问http://私有仓库服务器 ip5000/v2/_catalog
文章来源地址https://www.toymoban.com/news/detail-441235.html
从私有仓库拉取镜像
- 首先把之前的镜像删除
[root@server-a ~]# docker rmi 192.168.10.128:5000/centos:7
Untagged: 192.168.10.128:5000/centos:7
Untagged: 192.168.10.128:5000/centos@sha256:dead07b4d8ed7e29e98de0f4504d87e8880d4347859d839686a31da35a3b532f
[root@server-a ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
app latest d8cb1b6dcd58 30 hours ago 488MB
nginx latest 605c77e624dd 16 months ago 141MB
openjdk latest 5f94f53bbced 16 months ago 471MB
tomcat latest fb5657adc892 16 months ago 680MB
registry latest b8604a3fe854 18 months ago 26.2MB
centos 7 eeb6ee3f44bd 20 months ago 204MB
- 拉取镜像
[root@server-a ~]# docker pull 192.168.10.128:5000/centos:7
7: Pulling from centos
Digest: sha256:dead07b4d8ed7e29e98de0f4504d87e8880d4347859d839686a31da35a3b532f
Status: Downloaded newer image for 192.168.10.128:5000/centos:7
192.168.10.128:5000/centos:7
[root@server-a ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
app latest d8cb1b6dcd58 30 hours ago 488MB
nginx latest 605c77e624dd 16 months ago 141MB
openjdk latest 5f94f53bbced 16 months ago 471MB
tomcat latest fb5657adc892 16 months ago 680MB
registry latest b8604a3fe854 18 months ago 26.2MB
192.168.10.128:5000/centos 7 eeb6ee3f44bd 20 months ago 204MB
centos 7 eeb6ee3f44bd 20 months ago 204MB
到了这里,关于Docker私有仓库的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!