简体   繁体   中英

Docker API login issue

I am trying to use rest API for docker repository, however I could not figure out correct parameters for a http request.

Our repo is a inhouse installation of Nexus.

The docker client works fine with it, I see this in dockerd logs:

docker --debug -l debug login -u ourdocker some-our-repo.com
 level=debug msg="Calling POST /v1.24/auth"
 level=debug msg="form data: {\"password\":\"*****\",\"serveraddress\":\"some-our-repo.com\",\"username\":\"ourdocker\"}"
 level=info msg="{Action=auth, Username=someuser, LoginUID=1001, PID=10208}"
 level=debug msg="AuthZ request using plugin rhel-push-plugin"
 level=debug msg="hostDir: /etc/docker/certs.d/some-our-repo.com"
 level=debug msg="hostDir: /etc/docker/certs.d/some-our-repo.com"
 level=debug msg="attempting v2 login to registry endpoint https://some-our-repo.com/v2/"
 level=debug msg="AuthZ response using plugin rhel-push-plugin"

However when I try to do the same using an HTTP client it does not work. I was following instructions eg from here . But I always hit 404 if method is GET or 400 if method is POST. Apparently I am using wrong URL, but I could not figure out which one to use. Eg here it's how I try it using curl

$ curl -v -s -H "Content-Type: application/json" -X POST -d '{"username": "ourdocker", "password": "somepwd"}' https://some-our-repo.com/v2/users/login/

error : ... 400 HTTP method POST is not supported by this URL

Any ideas what HTTP request URL should be used?

That would be very helpful if there is a way to show detailed HTTP request in dockerd logs so I could just use it as example... Is it possible?

Apparently our Nexus repository is tuned to a particular "User-Agent" in the HTTP requests, it only allows to authenticate if a user-agent has a "docker" string in it.

Unfortunately authentication failures are responded with 400 or 404 responses rather than 403 by Nexus, so it was very confusing.

I keep the answer in case someone will have a similar issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM