【问题标题】:Docker-swarm automatically pulling missing image from private docker-registryDocker-swarm 自动从私有 docker-registry 中提取丢失的图像
【发布时间】:2017-02-24 02:37:53
【问题描述】:

我们有一个 docker-swarm 集群。管理器节点持有我们私有 docker 注册表的凭证。当我们在其他节点上启动新容器时,可能需要从私有 docker 注册表中拉取镜像。

有没有办法告诉 crate 容器命令拉取图像(如果节点上不存在)并为其提供凭据?

例如:我们想从 swarm 管理器(具有私有 docker 注册表的凭据)调用以下命令:

docker create -e contraint:server==app docker.exampleRegistry.com/path/image:1.0.0

这应该会拉取图像并在另一个节点(标记为app)上启动一个容器。 docker 注册表docker.exampleRegistry.com 是私有的。但我们得到:

Error response from daemon: unauthorized: authentication required

【问题讨论】:

    标签: authentication docker docker-registry docker-swarm


    【解决方案1】:

    知道了! docker cli 可能无法做到这一点(我们的 java 驱动程序也不是),但 docker 远程 API 可以使用 X-Registry-Auth 标头来提供凭据:

    curl -v -X POST -H "Content-Type: application/json"\
    -H "X-Registry-Auth: <base64ecoded({"username": "string", "password": "string", "email": "string", "serveraddress" : "string", "auth": ""})>"\
    -d '{"Image": "docker.exampleRegistry.com/path/image:1.0.0", "Env": ["contraint:server==app"]}'\
    https://localhost:2376/containers/create?name=container \
    --key path_to_key \
    --cacert path_to_ca
    

    https://github.com/docker/docker/blob/master/docs/reference/api/docker_remote_api.md#authentication

    【讨论】:

      猜你喜欢
      • 2021-06-07
      • 1970-01-01
      • 1970-01-01
      • 2015-09-04
      • 1970-01-01
      • 1970-01-01
      • 2020-12-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多