Docker Registry14

2022-01-21 16:53:27 浏览数 (1)

创建一个registry

这个registry

  • 指定了卷
  • TLS加密
  • 基础认证

先清掉docker中同名的registry,然后再创建,否则会报冲突,也可以给这个registry改为其它名字

代码语言:javascript复制
[root@docker ~]# docker run -d -p 5000:5000 --restart=always --name registry 
> -v `pwd`/data:/data 
> -v `pwd`/certs:/certs 
> -v `pwd`/auth:/auth 
> -e "REGISTRY_AUTH=htpasswd" 
> -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" 
> -e "REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd" 
> -e "REGISTRY_HTTP_TLS_CERTIFICATE=/certs/docker.crt" 
> -e "REGISTRY_HTTP_TLS_KEY=/certs/docker.key" 
> registry:2
71de3ba937945006578d495ed09ec36ca141130e1e22b3083018b9d43a251767
[root@docker ~]# docker ps -a 
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                     PORTS                    NAMES
71de3ba93794        registry:2          "/bin/registry /etc/d"   4 seconds ago       Up 3 seconds               0.0.0.0:5000->5000/tcp   registry
3d9f0915226f        registry:2          "htpasswd -Bbn testus"   5 minutes ago       Exited (0) 5 minutes ago                            prickly_jang
27995af3fa59        registry:2          "htpasswd -Bbn testus"   2 hours ago         Exited (0) 2 hours ago                              gloomy_goldberg
[root@docker ~]#

尝试push一个镜像

代码语言:javascript复制
[root@h104 ~]# docker push docker:5000/ubuntu 
The push refers to a repository [docker:5000/ubuntu] (len: 1)

Head https://docker:5000/v2/ubuntu/blobs/sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4: no basic auth credentials
[root@h104 ~]#

报错是因为没有进行认证

0 人点赞