docker / cli

The Docker CLI
Apache License 2.0
4.77k stars 1.89k forks source link

docker push doesn't work for registry with url prefix. #5042

Open cupen opened 3 months ago

cupen commented 3 months ago

From https://forums.docker.com/t/docker-push-does-not-support-url-prefix/137709

Here is my nginx config for workaround.

location /registry {
    proxy_pass http://127.0.0.1:5000;

    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_read_timeout 900;
}

# NOTE: Workaround for docker cli push without prefix
# @https://forums.docker.com/t/docker-push-does-not-support-url-prefix/137709
# Nginx config:
#   client_body_buffer_size 128k;
#   client_max_body_size 50m;
location ~ ^/v2/(.*)$ {
    proxy_pass http://127.0.0.1:5000/registry/v2/$1;

    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_read_timeout 900;
}