Unable to push image to a docker registry configured as proxy cache
Asked Answered
B

2

17

I followed this guide to setup a Docker v2 Registry acting as a local proxy cache for Docker Hub images. My Docker daemon is configured with both --insecure-registry and --registry-mirror options pointing to the same registry instance.

When pulling images it works correctly by caching them to the local store.

The problem is that when I try to push an image to such local private registry, I get a weird UNSUPPORTED error. The registry log says:

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

If I disable proxy setting on the registry then the push works correctly. Am I missing something on the configuration or it is just that a private registry cannot act as a proxy cache at the same time?

Burp answered 9/11, 2015 at 13:29 Comment(0)
Q
37

Just ran into this myself. Turns out pushing to a private registry configured as a proxy is not supported. See

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

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

That is too bad. Now I will have to will have to setup the local proxy cache as a separate registry.

Quarry answered 9/11, 2015 at 19:42 Comment(2)
If they could specify it in the error messageLauter
Unfortunately, I haven't been able to get the pull through cache aspect to work, so I'll just have to remove that for now.Vexation
Y
0

@Konrad already linked to the explaination.

My solution requires the registry to persist its images on a docker volume, so that they stay available even when I kill & trash the container.

# 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

This fits my usual needs; I dunno if you can afford to throw away the container as I did (but theoretically you should; containers are supposed to be ephemeral).


Otherwise you'll have to docker save your-image:your-tag > your-image.tar, transfer it to the machine running your registry and then docker load -i your-image.tar. It's not ideal but should work.

Yolondayon answered 23/4, 2021 at 1:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.