系统环境: CentOS 7.2
192.168.11.138:docker仓库
192.168.11.211:客户端linux
138上下载registry镜像: docker pull registrydocker
下载完以后咱们经过该镜像启动一个容器json
1 docker run -d -p 5000:5000 --privileged=true -v /opt/registry:/tmp/registry --name=registry registry
-d 在后台执行ubuntu
-p 端口映射, 开放容器的5000端口安全
-v /opt/registry:/tmp/registry :默认状况下,会将仓库存放于容器内的/tmp/registry目录下,指定本地目录挂载到容器
–privileged=true :CentOS7中的安全模块selinux把权限禁掉了,参数给容器加特权,不加上传镜像会报权限错误(OSError: [Errno 13] Permission denied: ‘/tmp/registry/repositories/liibrary’)或者(Received unexpected HTTP status: 500 Internal Server Error)错误curl
本机上传镜像url
1 docker tag ubuntu:latest localhost:5000/ubuntu
2 docker push localhost:5000/ubuntu
查看仓库的镜像spa
curl http://localhost:5000/v2/_catalog
{"repositories":["ubuntu"]}code
curl http://localhost:5000/ubuntu/tags/list
{"name":"ubuntu","tags":["latest"]}blog
而后使用docker pull从咱们的私有仓库中获取ubuntu镜像,
1 docker push localhost:5000/ubuntu 2 docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
localhost:5000/ubuntu latest f975c5035748 4 days ago 112MB
registry latest d1fd7d86a825 2 months ago 33.3MB
在”/etc/docker/“目录下,建立”daemon.json“文件。在文件中写入: 若是有这个文件就在时面加一条 { "insecure-registries":["192.168.1.113:5000"] }