码迷,mamicode.com
首页 > 其他好文 > 详细

docker 自建私有仓库

时间:2015-03-16 19:32:34      阅读:130      评论:0      收藏:0      [点我收藏+]

标签:docker

docker 自建私有仓库


首先创建存储 镜像的目录 


mkdir -p /opt/registry


默认情况下,会将仓库存放于容器内的/tmp/registry目录下,这样如果容器被删除,则存放于容器中的镜像也会丢失,所以我们一般情况下会指定本地一个目录挂载到容器内的/tmp/registry下.



执行

docker pull registry                 #安装docker私有仓库


启动 registry

docker run -d -e SETTINGS_FLAVOR=dev -e STORAGE_PATH=/tmp/registry -v /opt/registry:/tmp/registry -p 5000:5000 registry


--------------------------------------------------------------------------

 可用 http://ip:5000    来访问 

---------------------------------------------------

 提示如下 表示启动完成

"\"docker-registry server\""

----------------------------------------------------


在客户机上面:

#docker images

dev                    latest              a7efdd5c0690        5 days ago          989.2 MB



#docker tag a7efdd5c0690 172.24.0.14:5000/dev  


#docker images

dev                    latest              a7efdd5c0690        5 days ago          989.2 MB

172.24.0.14:5000/dev   latest              a7efdd5c0690        5 days ago          989.2 MB







#docker push 172.24.0.14:5000/dev

-------------------------------------------------------------------------------------------------------------------------------------------------

提示如下:

2015/03/16 15:34:35 Error: Invalid registry endpoint https://172.24.0.12:5000/v1/: Get https://172.24.0.12:5000/v1/_ping: dial tcp 172.24.0.12:5000: connection refused. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry 172.24.0.12:5000` to the daemon‘s arguments. In the case of HTTPS, if you have access to the registry‘s CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/172.24.0.12:5000/ca.crt

-------------------------------------------------------------------------------------------------------------------------------------------------


解决办法 禁用https 验证

vi /etc/sysconfig/docker


在 OPTIONS=--selinux-enabled 后面添加  --insecure-registry 172.24.0.14:5000  


然后重启 docker !! 



在次运行

#docker push 172.24.0.14:5000/dev



提示如下 为成功

----------------------------------------------------------------------------------------------------------------------

The push refers to a repository [172.24.0.14:5000/dev] (len: 1)

Sending image list

Pushing repository 172.24.0.14:5000/dev (1 tags)

511136ea3c5a: Image successfully pushed 

5b12ef8fd570: Image successfully pushed 

88f9454e60dd: Image successfully pushed 

a7efdd5c0690: Image successfully pushed 

Pushing tag for rev [a7efdd5c0690] on {http://172.24.0.14:5000/v1/repositories/dev/tags/latest}

-------------------------------------------------------------------------------------------------------------------------




私有仓库查询方法

curl http://172.24.0.14:5000/v1/search


如下所示  有 dev 表示 上传成功

--------------------------------------------------------------------------------------------------------------------------

{"num_results": 1, "query": "", "results": [{"description": "", "name": "library/dev"}]}

--------------------------------------------------------------------------------------------------------------------------



在其他客户机上访问和下载私有仓库的镜像

docker pull 172.24.0.14:5000/dev



----------------------------------------------------------------------------------------------------------------------------

docker pull 172.24.0.14:5000/dev

Pulling repository 172.24.0.14:5000/dev

88f9454e60dd: Download complete 

511136ea3c5a: Download complete 

5b12ef8fd570: Download complete 

Status: Image is up to date for 172.24.0.14:5000/dev:latest

----------------------------------------------------------------------------------------------------------------------------


docker 自建私有仓库

标签:docker

原文地址:http://jicki.blog.51cto.com/1323993/1621194

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!