'Docker Registry with prefix has problem with Docker login
I just deployed a Docker Registry on my personal server. I set up TLS and basic authentication as described in the main Docker documentation.
I am able to access the repository via URL by specifying https://{HOST}/registry/v2. It prompts the basic authentication request and returns an empty JSON {}.
Unfortunately, when I try to login to the registry via Docker CLI by using the following command
$ docker login https://{HOST}/registry/
it prompts the request for user and password, but after that it returns
Error response from daemon: login attempt to https://{HOST}/v2/ failed with status: 404 Not Found
completely ignoring the fact that the registry has a prefix and it is not in the root of the host.
Do you have an idea on how to fix this?
Here are the main file I used for the deployment.
Deployment configuration files
docker-compose.yaml
version: '3.5'
services:
registry:
restart: always
image: registry:2
ports:
- 5000:5000
environment:
REGISTRY_AUTH: htpasswd
REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd
REGISTRY_AUTH_HTPASSWD_REALM: Registry Realm
REGISTRY_HTTP_PREFIX: /registry/
volumes:
- ./data:/var/lib/registry
- ./auth:/auth
nginx location configuration
location /registry/ {
# Do not allow connections from docker 1.5 and earlier
# docker pre-1.6.0 did not properly set the user agent on ping, catch "Go *" user agents
if ($http_user_agent ~ "^(docker\/1\.(3|4|5(?!\.[0-9]-dev))|Go ).*$" ) {
return 404;
}
proxy_pass http://localhost:5000;
proxy_set_header Host $http_host; # required for docker client's sake
proxy_set_header X-Real-IP $remote_addr; # pass on real client's IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 900;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
