Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buildx can't push to artifactory or other repos that don't have /oauth/token as their token endpoint #1178

Open
scr-oath opened this issue Jun 21, 2022 · 8 comments

Comments

@scr-oath
Copy link

When pushing final image using docker buildx build to an enterprise artifactory docker registry, auth seems to fail

I suspect that the request is looking directly for /oauth/token endpoint, regardless of the WWW-Authenticate response.

$ curl -v https://${DOCKER_REGISTRY}/v2/scr/tst-multi-platform/tags/list |& grep WWW
< WWW-Authenticate: Bearer realm="https://${DOCKER_REGISTRY}/artifactory/api/docker/registry/v2/token",service="${DOCKER_REGISTRY}:4443",scope="repository:scr/tst-multi-platform:pull"
@tonistiigi
Copy link
Member

We should use WWW-Authenticate properly and no hardcoded endpoint addresses https://github.com/moby/buildkit/blob/a6a114a1a476c99c2501aa34811159b849df4005/vendor/github.com/containerd/containerd/remotes/docker/auth/fetch.go#L118 . Maybe someone from Artifactory can look at it. The auth code mostly comes from containerd repository.

@scr-oath
Copy link
Author

Hmm… well that's strange… I'll try to do some more debugging when I get a chance and wireshark if possible to see what's being sent returned… unless you have some recommendations for enabling/collecting debugging logs

@100tomer
Copy link

any news about this?

@MartinLoeper
Copy link

Wow, does that mean, we cannot use buildkit with harbor and similar registries at the moment? I am trying to get things working but buildx always complains about POST /service/token not being available on the harbor registry. Bummer :(

@100tomer
Copy link

Wow, does that mean, we cannot use buildkit with harbor and similar registries at the moment? I am trying to get things working but buildx always complains about POST /service/token not being available on the harbor registry. Bummer :(

For my private repository, Buildx fails to utilize the token obtained from the docker login command, leading the repository to perceive every request as an unauthenticated request that leads to 401 unauthorized responses.

@tonistiigi
Copy link
Member

buildx always complains about POST /service/token not being available on the harbor registry.

/service/token is not any hardcoded endpoint in buildx/buildkit. If your registry returns 401 with WWW-Authenticate that requests a token from /service/token but at the same time does not implement it, then there is not much a client can do.

@100tomer
Copy link

buildx always complains about POST /service/token not being available on the harbor registry.

/service/token is not any hardcoded endpoint in buildx/buildkit. If your registry returns 401 with WWW-Authenticate that requests a token from /service/token but at the same time does not implement it, then there is not much a client can do.

Can you assist me in resolving this issue? In my specific case, the server responds with the “WWW-Authenticate” header, along with a URL path that the buildx should utilize. However, despite this, the token is not being transmitted to the Docker push HTTP requests.

@MartinLoeper
Copy link

MartinLoeper commented Oct 27, 2024

@tonistiigi Thanks for the insights! I checked the current goharbor implementation and noticed that they implemented the token endpoint via GET method. However, the WWW-Authenticate Header does not carry the HTTP method AFAIK. The current buildx implementation responds to the WWW-Authenticate response header by doing a POST request. Is there some wiggle room in the spec? At least that would explain why it is not working despite goharbor claiming to have implemented the spec.

My current workaround is to set BUILDKIT_NO_CLIENT_TOKEN=true during docker buildx build [...] --push as mentioned here: #1613 (comment)

see also:

might also be the cause of confusion for e.g.:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants