Skip to content
New issue

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

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

Already on GitHub? # to your account

Fetching Image From Public Registry Results in HTTP 401 on Windows 11 Under WSL2 Through Rancher Desktop #1589

Closed
1 task
donmai2024 opened this issue Dec 16, 2024 · 4 comments
Labels
bug Something isn't working triage New issues or PRs to be acknowledged by maintainers

Comments

@donmai2024
Copy link

What happened in your environment?

Hello,

oras fails authorization when ran via WSL2 through Rancher Desktop to pull from a public GitHub container registry.

Example CLI log:

/mnt/wsl/rancher-desktop/run/data/ # oras manifest fetch --debug --verbose ghcr.io/jonashackt/hello-world:latest
DEBU[0000] Request #0
> Request URL: "https://ghcr.io/v2/jonashackt/hello-world/manifests/latest"
> Request method: "GET"
> Request headers:
   "Accept": "application/vnd.docker.distribution.manifest.v2+json, application/vnd.docker.distribution.manifest.list.v2+json, application/vnd.oci.image.manifest.v1+json, application/vnd.oci.image.index.v1+json, application/vnd.oci.artifact.manifest.v1+json"
   "User-Agent": "oras/1.2.1"
DEBU[0000] Response #0
< Response Status: "401 Unauthorized"
< Response headers:
   "Content-Length": "73"
   "X-Github-Request-Id": "C778:3ED69D:CE2642:E9A965:67603DE8"
   "Content-Type": "application/json"
   "Www-Authenticate": "Bearer realm=\"https://ghcr.io/token\",service=\"ghcr.io\",scope=\"repository:jonashackt/hello-world:pull\""
   "Date": "Mon, 16 Dec 2024 14:49:12 GMT"
Error: failed to fetch the content of "ghcr.io/jonashackt/hello-world:latest": GET "https://ghcr.io/v2/jonashackt/hello-world/manifests/latest": exit status 28

docker config.json

{
  "credsStore": "rancher-desktop"
}

What did you expect to happen?

The manifest and images to be pulled to my local workstation.

How can we reproduce it?

  1. Install Rancher Desktop on a Windows 11 host machine
  2. Install WSL2
  3. Use rancher-desktop as your distribution for WSL2
  4. Use docker login in the Windows host, so that your credentials are in the Windows Credential Manager
  5. Run oras manifest fetch in the WSL2 shell against a public image of your choice

What is the version of your ORAS CLI?

/mnt/wsl/rancher-desktop/run/data # oras version
Version:        1.2.1
Go version:     go1.23.4
Git commit:     a0228556766b6276010d8feb937af512e8a50808
Git tree state: clean

What is your OS environment?

Windows 11, WSL2, Rancher-Desktop

Are you willing to submit PRs to fix it?

  • Yes, I am willing to fix it.
@donmai2024 donmai2024 added bug Something isn't working triage New issues or PRs to be acknowledged by maintainers labels Dec 16, 2024
@Wwwsylvia
Copy link
Member

Hi @donmai2024 , it looks like your scenario is saving the credentials in wincred in Windows host and reading it from rancher-desktop in WSL? Is the expectation that rancher-desktop should automatically sync the credentials in wincred?

If so, you may get the credentials from wincred in Windows:

echo "ghcr.io" | docker-credential-wincred get

Do the same from rancher-desktop in WSL:

echo "ghcr.io" | docker-credential-rancher-desktop get

And see if the credentials match.

I tried to reproduce this in my environment, but docker-credential-rancher-desktop hangs. There might be something tricky with this credentials helper. 🤔

@donmai2024
Copy link
Author

Hello @Wwwsylvia,

it looks like your scenario is saving the credentials in wincred in Windows host and reading it from rancher-desktop in WSL? Is the expectation that rancher-desktop should automatically sync the credentials in wincred?

Yes. That's how I hope it would work.

If so, you may get the credentials from wincred in Windows:

echo "ghcr.io" | docker-credential-wincred get

This returns my Github credentials.

Do the same from rancher-desktop in WSL:

echo "ghcr.io" | docker-credential-rancher-desktop get

This returns nothing.

I tried to reproduce this in my environment, but docker-credential-rancher-desktop hangs. There might be something tricky with this credentials helper. 🤔

This hung for me too. I let it run for about 5-10 minutes, and then it completed with no output (but it did return control to the system). The credential helper seems to be a shell script calling curl against a rancher endpoint.

@Wwwsylvia
Copy link
Member

@donmai2024 It doesn't look like rancher-desktop can automatically sync credentials from docker desktop. You may need to find a workable credentials helper to use in rancher-desktop.

This hung for me too. I let it run for about 5-10 minutes, and then it completed with no output (but it did return control to the system). The credential helper seems to be a shell script calling curl against a rancher endpoint.

This is more of a set-up issue with rancher-desktop then. ORAS relies on docker credentials helpers (or config files for plaintext credentials) to read/save credentials but does not provide a credentials store itself.

@donmai2024
Copy link
Author

@Wwwsylvia, thank you for the insights and support! As you say, it seems to be a problem with rancher-desktop, so I will close this issue.

For a closing note: I have found a potential workaround that I'll need to look into more on my end. By updating the docker config.json from this:

{
  "credsStore": "rancher-desktop"
}

to this:

{
  "credsStore": "wincred"
}

I was able to use oras manifest fetch on public and private images. In my mind, this further points to it being a problem on rancher-desktop's end.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working triage New issues or PRs to be acknowledged by maintainers
Projects
None yet
Development

No branches or pull requests

2 participants