container icon indicating copy to clipboard operation
container copied to clipboard

[Bug]: container is trying to reach ghcr.io when running a container using an image from a different repository

Open dkovba opened this issue 1 year ago • 2 comments

I have done the following

  • [x] I have searched the existing issues
  • [x] If possible, I've reproduced the issue using the 'main' branch of this project

Steps to reproduce

  1. Generate a new token (classic) on https://github.com/settings/tokens, check write:packages.
  2. Login to ghcr.io: bin/container registry login ghcr.io -u <USERNAME> (use the generated token as password).
  3. Open the Keychain, search for "ghcr.io", open the password, click "Show password", and modify the password to make it invalid.
  4. Run: bin/container system stop, and bin/container system start.
  5. Run: bin/container run -it --rm docker.io/library/swift:latest date

Current behavior

Can't run a container:

Error: unknown: "HTTP request to https://ghcr.io/token?client_id=containerization-registry-client&service=ghcr.io&scope=repository:user/image:pull failed with response: 403 Forbidden"

Expected Behavior

A container runs.

Environment

- macOS: 26 beta
- Swift: 6.1
- Xcode: 26 beta
- container: main

Relevant log output

Notes:
As a workaround, remove the added password in the Keychain and repeat steps 4 and 5 (no need to log in to ghcr.io again).

Code of Conduct

  • [x] I agree to follow this project's Code of Conduct

dkovba avatar Jun 13 '25 00:06 dkovba

I believe it tries to reach the default init image, which is ghcr.io/apple/containerization/vminit, and since you have creds in the keychain it tries to login.

So it's not related to the image you try to run. In theory, there is an option to add a flag or a func that will allow skipping auth for system images, but in this case user can hit some rate limits. Another option is to embed those images into binary and don't pull them at all, but it requires quite a bit of effort, increases the binary size and deprives the opportunity to patch CVEs in those images.

So, I would say, the current state is one of the best options, but it needs to be properly documented.

makhov avatar Jun 13 '25 08:06 makhov

Indeed, that's what's happening. We may consider printing that we're attempting to download the init image under this issue.

dkovba avatar Jun 13 '25 18:06 dkovba