dockerRegistry


原文链接: dockerRegistry

纯HTTP的Registry

从官方拉取一个Registry

$ docker run -d -p 5000:5000 --restart=always --name registry -vpwd/data:/var/lib/registry registry:2

修改docker1.12版 Registry server 以及所有要访问Registry server的client端,让其支持HTTP传输(默认是HTTPS传输)

vi /etc/docker/daemon.json
$ { "insecure-registries":["youripordomain:5000"] }

$ docker pull ubuntu
$ docker tag ubuntu oo3p.com:5000/ubuntu
$ docker push oo3p.com:5000/ubuntu
$ docker pull oo3p.com:5000/ubuntu

TLS认证

$ mkdir auth -p

创建密码文件,替换用户名:testuser,密码:testpassword

$ docker run --entrypoint htpasswd registry:2 -Bbn testuser testpassword > auth/htpasswd

停止registry,然后用下面的代码再次启动

$ docker run -d -p 5000:5000 --restart=always --name registry
-v /data/registry:/var/lib/registry
-v ~/auth:/auth
-e "REGISTRY_AUTH=htpasswd"
-e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm"
-e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd
-v ~/certs:/certs
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt
-e REGISTRY_HTTP_TLS_KEY=/certs/domain.key
registry:2

然后登录

$ docker login www.oo3p.com:5000

`