无法将图像推送到配置为代理缓存的 docker 注册表

Unable to push image to a docker registry configured as proxy cache

我按照 this 指南设置了一个 Docker v2 注册表作为 Docker 集线器图像的本地代理缓存。我的 Docker 守护程序配置有指向同一注册表实例的 --insecure-registry--registry-mirror 选项。

拉取图像时,它会通过将图像缓存到本地存储来正常工作。

问题是,当我尝试将图像推送到此类本地私有注册表时,出现了一个奇怪的 UNSUPPORTED 错误。注册表日志显示:

time="2015-11-09T13:20:22Z" level=error msg="response completed with error" err.code=UNSUPPORTED err.message="The operation is unsupported." go.version=go1.4.3 http.request.host="my.registry.io:5000" http.request.id=b1faccb3-f592-4790-bbba-00ebb3a3bfc1 http.request.method=POST http.request.remoteaddr="192.168.0.4:57608" http.request.uri="/v2/mygroup/myimage/blobs/uploads/" http.request.useragent="docker/1.9.0 go/go1.4.2 git-commit/76d6bc9 kernel/3.16.0-4-amd64 os/linux arch/amd64" http.response.contenttype="application/json; charset=utf-8" http.response.duration=2.035918ms http.response.status=405 http.response.written=78 instance.id=79970ec3-c38e-4ebf-9e83-c3890668b122 vars.name="mygroup/myimage" version=v2.2.0

如果我在注册表中禁用代理设置,则推送工作正常。我是不是在配置上遗漏了什么,或者只是私有注册表不能同时充当代理缓存?

只是 运行 我自己。事实证明,不支持推送到配置为代理的私有注册表。见

https://docs.docker.com/registry/configuration/#proxy

"Pushing to a registry configured as a pull through cache is currently unsupported".

太糟糕了。现在我必须将本地代理缓存设置为单独的注册表。

@Konrad 已经链接到解释。

我的解决方案要求注册表将其映像保存在 docker 卷上,这样即使我终止并丢弃容器,它们也仍然可用。

# run proxy registry persisting images on local host
docker stop registry
docker rm registry
docker run -d -p 5000:5000
    -v ~/.docker/registry:/var/lib/registry \
    --name registry \
    registry:2
docker push localhost:5000/your-image:your-tag
# --> see successful push happening...
docker stop
docker rm registry
# re-run the registry as proxy, re-mounting the volume with the images
docker run -d -p 5000:5000 \
    -e MIRROR_SOURCE=https://registry.example.net \
    -e REGISTRY_PROXY_REMOTEURL=https://registry.example.net \
    -e REGISTRY_PROXY_USERNAME="${REGISTRY_USER}" \
    -e REGISTRY_PROXY_PASSWORD="${REGISTRY_PASSWORD}" \
    -v ~/.docker/registry:/var/lib/registry \
    --name registry \
    registry:2

这符合我平时的需要;我不知道你是否有能力像我一样扔掉容器(但理论上你应该这样做;容器应该是短暂的)。


否则,您将不得不 docker save your-image:your-tag > your-image.tar,将其传输到计算机 运行 您的注册表,然后 docker load -i your-image.tar。这并不理想,但应该可以。