环境:
centos 7.2 X64
jdk1.8
一、首先安装 docker
yum -y install docker
systemctl start docker
systemctl enable docker
二、下载私有仓库有镜像
docker pull registry
关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
三、运行私有仓库
docker run -d -p 5000:5000 --restart always -v /opt/data/registry:/tmp/registry registry
参数说明:
-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)错误
四、修改/etc/sysconfig/docker(Ubuntu下配置文件地址为:/etc/init/docker.conf),增加启动选项
OPTIONS='--selinux-enabled --insecure-registry 172.172.177.75:5000'
重启docker
systemctl restart docker
五、测试私有仓库
docker pull hello-world
docker tag hello-world 172.172.177.75:5000/hello-world
其推送到私有仓库:
docker push 172.172.177.75:5000/hello-world
下载镜像
docker pull 172.172.177.75:5000/hello-world
查看仓库中镜像
http://172.172.177.75:5000/v2/_catalog