docker registry 的使用

本贴最后更新于 1450 天前,其中的信息可能已经沧海桑田

参考资料:

资料

最佳实践

  1. Create a password file with one entry for the user testuser, with password testpassword:

    $ mkdir auth
    $ docker run \
      --entrypoint htpasswd \
      registry:2 -Bbn testuser testpassword > auth/htpasswd
    
    
  2. Stop the registry.

    $ docker container stop registry
    
    
  3. 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
    
    
  4. Try to pull an image from the registry, or push an image to the registry. These commands fail.

  5. 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
  • Docker

    Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的操作系统上。容器完全使用沙箱机制,几乎没有性能开销,可以很容易地在机器和数据中心中运行。

    476 引用 • 899 回帖

相关帖子

欢迎来到这里!

我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。

注册 关于
请输入回帖内容 ...