Search code examples
dockerartifactory

Unable to login to Docker registry on Artifactory


I am able to get a token with:

(base) ➜  ~ curl artifactory.example.com/artifactory/api/docker/null/v2/token -u myusername:mypassword
{"token":"mytoken","expires_in":3600}

However when I try to login:

(base) ➜  ~ docker login artifactory.example.com -u myusername -p mypassword
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Error response from daemon: Get http://artifactory.example.com/v2/: error parsing HTTP 404 response body: invalid character '<' looking for beginning of value: "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>404 Not Found</title>\n</head><body>\n<h1>Not Found</h1>\n<p>The requested URL /artifactory/api/docker/null/v2/token was not found on this server.</p>\n</body></html>\n"

It's like it's trying to do http://artifactory.example.com/v2/artifactory/api/docker/null/v2/token when it should be doing http://artifactory.example.com/artifactory/api/docker/null/v2/token?


Solution

  • The registry API requires that it is at the root of the url, and will not work under a path based reverse proxy. You need to allocate either a port or hostname to the docker API that responds to a request for /v2 on that hostname. Artifactory implements this by giving you a reverse proxy config generator.