私有Docker Rigistry的搭建问题

 

开发中如果使用docker镜像,因为网速问题,使用dockerhub不是很方便,于是想在公司内部搭建私有的Registry。

首先,在服务器上安装docker

如果使用apt-get install docker安装ubuntu自带的docker,可能版本比较低,这样有可能在docker pull时会遇到:

Could not reach any registry endpoint 这样的错误。

解决方案就是安装docker提供的版本:

#apt-get install -y curl

#curl -sSL https://get.docker.com/ | sudo sh

 

其次,安装docker registry镜像

#git clone https://github.com/docker/docker-registry.git

#mkdir -p /opt/data/registry

#cd docker-registry

#docker build

 

创建好镜像后,运行镜像

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

 

 

这样,私有registry就搭建好了,可以向上面传输镜像了

#docker push 127.0.0.1:5000/ubuntu:12.04

报错:

The push refers to a repository [127.0.0.1:5000/utuntu] (len: 1)
Repository does not exist: 127.0.0.1:5000/utuntu

执行 

#docker tag ubuntu:12.04 127.0.0.1:5000/ubuntu:12.04

再上传

#docker push 127.0.0.1:5000/ubuntu:12.04,上传成功。

通过命令:

#curl -X GET http://127.0.0.1:5000/v1/search

查看Registry上的镜像,返回:

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

 

 

上面的步骤只实现了在本地上传镜像,如果需要在其他机器上上传镜像,可能还需要其他的步骤。

 

 

posted @ 2016-04-08 16:09  cooltank  阅读(2955)  评论(0编辑  收藏  举报