参考资料:
最佳实践
-
Create a password file with one entry for the user
testuser
, with passwordtestpassword
:$ mkdir auth $ docker run \ --entrypoint htpasswd \ registry:2 -Bbn testuser testpassword > auth/htpasswd
-
Stop the registry.
$ docker container stop registry
-
Start the registry with basic authentication.
$ docker run -d \ -p 5000:5000 \ --restart=always \ --name registry \ -v "$(pwd)"/auth:/auth \ -e "REGISTRY_AUTH=htpasswd" \ -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \ -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \ -v "$(pwd)"/certs:/certs \ -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt \ -e REGISTRY_HTTP_TLS_KEY=/certs/domain.key \ registry:2
-
Try to pull an image from the registry, or push an image to the registry. These commands fail.
-
Log in to the registry.
$ docker login myregistrydomain.com:5000
Provide the username and password from the first step.
Test that you can now pull an image from the registry or push an image to the registry.
登录
docker login -u 用户名 -p 密码
docker logout
推送和拉取
Tag the image so that it points to your registry
docker image tag ubuntu localhost:5000/myfirstimage
Push it
docker push localhost:5000/myfirstimage
Pull it back
docker pull localhost:5000/myfirstimage
查看镜像:
curl -X GET https://55.example.com:443/v2/_catalog -uadmin:DO1registry2
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于