[Bug]: container is trying to reach ghcr.io when running a container using an image from a different repository
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
- Generate a new token (classic) on https://github.com/settings/tokens, check
write:packages. - Login to ghcr.io:
bin/container registry login ghcr.io -u <USERNAME>(use the generated token as password). - Open the Keychain, search for "ghcr.io", open the password, click "Show password", and modify the password to make it invalid.
- Run:
bin/container system stop, andbin/container system start. - 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
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.
Indeed, that's what's happening. We may consider printing that we're attempting to download the init image under this issue.