开发中若是使用docker镜像,由于网速问题,使用dockerhub不是很方便,因而想在公司内部搭建私有的Registry。git
若是使用apt-get install docker安装ubuntu自带的docker,可能版本比较低,这样有可能在docker pull时会遇到:github
Could not reach any registry endpoint 这样的错误。docker
解决方案就是安装docker提供的版本:ubuntu
#apt-get install -y curl服务器
#curl -sSL https://get.docker.com/ | sudo shcurl
#git clone https://github.com/docker/docker-registry.gitui
#mkdir -p /opt/data/registryurl
#cd docker-registryspa
#docker buildip
#docker run -d -e SETTINGS_FLAVOR=dev -e STORAGE_PATH=/tmp/registry -v /opt/data/registry:/tmp/registry -p 5000:5000 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"}]}
上面的步骤只实现了在本地上传镜像,若是须要在其余机器上上传镜像,可能还须要其余的步骤。