Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Docker compose 如何传递用户名&;“私人Docker注册表”的密码;htpasswd";认证_Docker Compose_Docker Registry - Fatal编程技术网

Docker compose 如何传递用户名&;“私人Docker注册表”的密码;htpasswd";认证

Docker compose 如何传递用户名&;“私人Docker注册表”的密码;htpasswd";认证,docker-compose,docker-registry,Docker Compose,Docker Registry,我有一个docker注册表:2使用docker compose和“htpasswd”身份验证实现。 这是完美的工作。我可以通过在终端上传递凭据,使用“docker login”命令登录到注册表。 可以执行所有docker推/拉操作。 但是,curl查询由于身份验证错误而失败 curl-s-H“Content-Type:application/json”-X POST-d'{“username”:“registry admin”,“password”:Password@123“}” 错误: {“e

我有一个docker注册表:2使用docker compose和“htpasswd”身份验证实现。 这是完美的工作。我可以通过在终端上传递凭据,使用“docker login”命令登录到注册表。 可以执行所有docker推/拉操作。 但是,curl查询由于身份验证错误而失败

curl-s-H“Content-Type:application/json”-X POST-d'{“username”:“registry admin”,“password”:Password@123“}”

错误: {“errors”:[{“code”:“UNAUTHORIZED”,“message”:“authentication required”,“detail”:[{“Type”:“registry”,“Class”:“Name”:“catalog”,“Action”:“*”}]}

Docker-Compose.yml

version: '3.7'

services:
  my-registry:
    container_name: my-registry
    restart: always
    image: registry:2
    ports:
    - "5000:5000"
    environment:
      REGISTRY_HTTP_ADDR: 0.0.0.0:5000
      REGISTRY_HTTP_TLS_CERTIFICATE: /certs/domain.crt
      REGISTRY_HTTP_TLS_KEY: /certs/domain.key
      REGISTRY_AUTH: htpasswd
      REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd
      REGISTRY_AUTH_HTPASSWD_REALM: Registry Realm
      REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY: /data
    volumes:
      - type: bind
        source: /opt/docker/registry/certs/
        target: /certs
      - type: volume
        source: registry_data
        target: /data
      - type: bind
        source: /opt/docker/registry/auth/
        target: /auth  

volumes:
  registry_data:

将“htpasswd”凭据与CURL命令一起用于列出注册表映像之类的操作的正确方法是什么?

您可以使用CURL对私有docker注册表的请求进行身份验证,如:

curl --user ${user}:${password} http://${domain}:${port}/v2/*
在您的用例中,这应该是:

curl --user regisrty-admin:Password@123 https://my-registry.com:5000/v2/_catalog

您可以使用curl对私人docker注册表的请求进行身份验证,如:

curl --user ${user}:${password} http://${domain}:${port}/v2/*
在您的用例中,这应该是:

curl --user regisrty-admin:Password@123 https://my-registry.com:5000/v2/_catalog

可能您正在寻找这一有用的方法,但我知道,目前还不支持通过curl将凭证传递到Registry:2。此功能可能在Docker registry的最新版本中实现:2您能否在PrashantShetage提供此信息的源代码?可能您正在寻找此功能是否有用,但我知道,目前不支持通过curl将凭据传递到注册表:2。此功能可能在Docker registry的最新版本中实现:2您能否在@PrashantShetage提供此信息的源代码?