yujin2010good
作者yujin2010good·2018-12-14 14:28
系统工程师·大型零售巨头

docker学习六--私有库安装配置使用

字数 3196阅读 1590评论 1赞 3

1、安装完docker之后,可以通过registry镜像来简单搭建一套私有仓库。

[root@ip-10-249-100-205 ~]# docker run -d -p 5000:5000 registry

下载完成之后自动启动一个registry容器,创建本地的私有仓库服务。
默认情况下仓库会创建在容器的/tmp/registry目录下,可以使用-v参数将镜像温江存放在本地指定的路径。

docker run -d -p 5000:5000 -v /data/registry:/tmp/registry registry

2、客户机上测试

先修改tag信息

[root@bogon ~]# docker tag docker.io/centos:latest 10.249.100.205:5000/centos
[root@bogon ~]# docker images
REPOSITORY                               TAG                 IMAGE ID            CREATED             SIZE
192.168.202.12:5000/bf-reports/logc      latest              13cbc1051e26        2 days ago          206.4 MB
192.168.202.12:5000/bf-reports/web       latest              83a6f662cb77        2 days ago          204.7 MB
192.168.202.12:5000/bf-reports/app       latest              4982bb69ba1d        2 days ago          215.1 MB
hub.c.163.com/lovego/xiaomei/logc        latest              7a8cdeef9fc7        9 weeks ago         206.4 MB
docker.io/registry                       latest              177391bcf802        3 months ago        33.26 MB
10.249.100.205:5000/centos               latest              3fa822599e10        3 months ago        203.5 MB
docker.io/centos                         latest              3fa822599e10        3 months ago        203.5 MB
hub.c.163.com/lovego/xiaomei/nginx       latest              0c8707e1f509        3 months ago        197.6 MB
hub.c.163.com/lovego/xiaomei/appserver   latest              1d5230131e77        3 months ago        190.6 MB

问题:

[root@bogon ~]# docker push 10.249.100.205:5000/centos
The push refers to a repository [10.249.100.205:5000/centos]
Get https://10.249.100.205:5000/v1/_ping: http: server gave HTTP response to HTTPS client
处理
[root@bogon ~]# vi /etc/docker/daemon.json 
{ "insecure-registries":["10.249.100.205:5000"] }

重启

[root@bogon ~]# service docker restart
Redirecting to /bin/systemctl restart docker.service
[root@bogon ~]# docker push 10.249.100.205:5000/centos
The push refers to a repository [10.249.100.205:5000/centos]
d1be66a59bc5: Pushed 
latest: digest: sha256:3a32a170c945ffe18334b3f514fcb66f9c14001b2266c9ed8504c72db0acde11 size: 529
上传到私有库
[root@bogon ~]# docker push 10.249.100.205:5000/test
The push refers to a repository [10.249.100.205:5000/test]
32fe1ce02eb9: Pushed 
c07e996d727b: Pushed 
4b6aec5030f1: Pushed 
ccb7ab190dd6: Pushed 
df7cd7f81dc3: Pushed 
28f6de911d7d: Pushed 
174a611570d4: Pushed 
f51f76255b02: Pushed 
51db18d04d72: Pushed 
f1c896f31e49: Pushed 
0f5ff0cf6a1c: Pushed 
latest: digest: sha256:4a161fe6e9d5cdd01bd59bdaad17ce68b5bb60e9df6cec7c52c93ae2ce578485 size: 2611

下载

[root@localhost registry]# docker pull 10.249.100.205:5000/test
Using default tag: latest
Trying to pull repository 10.249.100.205:5000/test ... 
latest: Pulling from 10.249.100.205:5000/test
Digest: sha256:4a161fe6e9d5cdd01bd59bdaad17ce68b5bb60e9df6cec7c52c93ae2ce578485
[root@localhost registry]# docker images
REPOSITORY                               TAG                 IMAGE ID            CREATED             SIZE
10.249.100.205:5000/test                 latest              0c8707e1f509        3 months ago        197.6 MB

3、进入容器查看上传成功的镜像

/var/lib/registry/docker/registry/v2/repositories # ls 
centos  test    wolf

成功

如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!

3

添加新评论1 条评论

wuwenpinwuwenpin软件开发工程师南京
2018-12-21 17:51
感谢分享!
Ctrl+Enter 发表

作者其他文章

相关文章

相关问题

相关资料

X社区推广