container icon indicating copy to clipboard operation
container copied to clipboard

[Bug]: Pulling private images fails

Open skinny opened this issue 1 year ago • 17 comments

I have done the following

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

Steps to reproduce

Using the 0.6.0 release on MacOS 26.0.1 I'm trying to pull an image from a private registry on Azure which fails with a -25308 error. Looks very similar to https://github.com/apple/container/issues/532. I tried this with ssh and via terminal in the GUI. Both produce the same result (see below)

Current behavior

Logging in now works (was previously also failing) :

Provide registry username mycompreg.azurecr.io: mycompreg-pull
Provide registry password:
Login succeeded

But trying to pull an image right after fails with :

Error: internalError: "error querying keychain for mycompreg.azurecr.io (cause: "queryError("query failure: unhandledError(status: -25308)")")"

Relevant logs :

Timestamp                       Thread     Type        Activity             PID    TTL
2025-10-28 14:54:17.694513-0700 0x6655     Default     0x0                  2715   0    secd: [com.apple.securityd:SecError] SecDbKeychainItemV7: cannot decrypt metadata key because the keychain is locked (-25308)
2025-10-28 14:54:17.694530-0700 0x6657     Default     0x0                  2715   0    secd: [com.apple.securityd:SecError] decode item failed, keychain is locked (-25308)
2025-10-28 14:54:17.772080-0700 0x6645     Error       0x0                  2713   0    container-core-images: [com.apple.container:ImagesHelper] handler for imagePull threw error internalError: "error querying keychain for mycompreg.azurecr.io" (cause: "query Error("query failure: unhandledError(status: -25308)")")
2025-10-28 14:56:37.636240-0700 0x6750     Error       0x0                  2713   0    container-core-images: [com.apple.container:ImagesHelper] handler for imagePull threw error internalError: "error querying keychain for mycompreg.azurecr.io" (cause: "queryError("query failure: unhandledError(status: -25308)")")
2025-10-28 14:56:46.535728-0700 0x68bd     Error       0x0                  2713   0    container-core-images: [com.apple.container:ImagesHelper] handler for imagePull threw error internalError: "error querying keychain for mycompreg.azurecr.io" (cause: "queryError("query failure: unhandledError(status: -25308)")")
2025-10-28 14:57:10.240262-0700 0x69ba     Error       0x0                  2713   0    container-core-images: [com.apple.container:ImagesHelper] handler for imagePull threw error internalError: "error querying keychain for mycompreg.azurecr.io" (cause: "queryError("query failure: unhandledError(status: -25308)")")
--------------------------------------------------------------------------------------------------------------------
Log      - Default:          2, Info:                0, Debug:             0, Error:          4, Fault:          0
Activity - Create:           0, Transition:          0, Actions:           0

Expected behavior

Pulling the image works

Environment

- OS: MacOS 26.0.1
- Container: 0.6.0

Relevant log output

N/A

Code of Conduct

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

skinny avatar Oct 28 '25 22:10 skinny

Hi @skinny, did you try logging out and back into your terminal?

Could you collect a sysdiagnose?

katiewasnothere avatar Oct 28 '25 22:10 katiewasnothere

@katiewasnothere Hi! I have tried restarting, reinstalling container, building it myself from the latest source code but all roads end up in the same place. How can I share I sysdiagnose with you ?

skinny avatar Oct 28 '25 22:10 skinny

Ok, new day, new results.

Restarted the system Logged in via UI, started Terminal and everything worked (keychain popup during container pull command)., Very curious if the setup keeps working every day like this.

However I'm still looking for a good way to do this headless (start a container via a LaunchDaemon)

skinny avatar Oct 29 '25 17:10 skinny

After another day of testing the whole process is flaky at best. I can succesfully perform a container registry login (either via ssh or terminal). The keychain entry appears correct. For the sake of testing I have set the item to "always allow access". Trying to pull an image from the specific registry fails with either a 401 Unauthorized or the aforementioned unhandled -25308 error.

Every step was performed with the same user account via both ssh and directly via a login session.

Unfortunately getting reliable access to our private images is a requirement for further testing and implementation of this beautiful project

skinny avatar Oct 30 '25 02:10 skinny

I'm using the 0.6.0 signed installer package. Pulling a private image from the Terminal now triggers the OS to show the Keychain access prompt, even when I have added "/usr/local/libexec/container/plugins/container-core-images/bin/container-core-images" to the keychain entry.

The securityd logs show :

Filtering the log data using "subsystem == "com.apple.securityd""
Timestamp                       Thread     Type        Activity             PID    TTL  
2025-10-30 11:06:14.146247-0700 0x5e04     Default     0x20dc8              1488   0    container-core-images: (Security) [com.apple.securityd:thread-local-client-debug] SecSecurityClientGet new thread!
2025-10-30 11:06:14.152788-0700 0x9c2      Default     0x0                  143    0    securityd: [com.apple.securityd:KCdb] 0x8411ec780(0x841189200) is unlocked; decoding for makeUnlocked()
2025-10-30 11:06:14.154680-0700 0x55d5     Default     0x0                  143    0    securityd: [com.apple.securityd:clientid] code requirement check failed (-67050), client is not Apple-signed
2025-10-30 11:06:14.154754-0700 0x55d5     Default     0x0                  143    0    securityd: [com.apple.securityd:integrity] ACL partition mismatch: client cdhash:2339259f36d48452b87860874622b80a2b18c4ed ACL (
    "apple-tool:"
)
2025-10-30 11:06:14.154763-0700 0x55d5     Default     0x0                  143    0    securityd: [com.apple.securityd:integrity] asking user about XARA partition for 'cdhash:2339259f36d48452b87860874622b80a2b18c4ed'
2025-10-30 11:06:14.154775-0700 0x55d5     Default     0x0                  143    0    securityd: [com.apple.securityd:kcacl] Keychain query for process 1488 (UID 501)
2025-10-30 11:06:14.154783-0700 0x55d5     Default     0x0                  143    0    securityd: [com.apple.securityd:kcacl] client is valid, proceeding
2025-10-30 11:06:14.154922-0700 0x55d5     Default     0x0                  143    0    securityd: [com.apple.securityd:clientid] code requirement check failed (-67050), client is not Apple-signed
2025-10-30 11:06:14.154968-0700 0x55d5     Default     0x0                  143    0    securityd: [com.apple.securityd:kcacl] displaying keychain prompt for /usr/local/libexec/container/plugins/container-core-images/bin/container-core-images(1488); ACL: <AclValidationContext(action:65538)SUBJECT[not-init]OBJECT[not-init]>
2025-10-30 11:06:14.155034-0700 0x55d5     Default     0x0                  143    0    securityd: [com.apple.securityd:SecurityAgentConnection] new SecurityAgentConnection(0x16ba26410)
2025-10-30 11:06:14.155054-0700 0x55d5     Default     0x0                  143    0    securityd: [com.apple.securityd:SecurityAgentXPCQuery] new SecurityAgentXPCQuery(0x16ba26410)
2025-10-30 11:06:14.155194-0700 0x55d5     Default     0x0                  143    0    securityd: [com.apple.securityd:clientid] code requirement check failed (-67050), client is not Apple-signed
2025-10-30 11:06:14.155214-0700 0x55d5     Default     0x0                  143    0    securityd: [com.apple.securityd:SecurityAgentConnection] activate(0x16ba26410)
2025-10-30 11:06:14.155280-0700 0x55d5     Default     0x0                  143    0    securityd: [com.apple.securityd:SecurityAgentXPCConnection] Retrieved UID 501 for this session
2025-10-30 11:06:14.155317-0700 0x55d5     Default     0x0                  143    0    securityd: [com.apple.securityd:SecurityAgentXPCConnection] Creating a standard security agent
2025-10-30 11:06:14.155424-0700 0x55d5     Default     0x0                  143    0    securityd: [com.apple.securityd:SecurityAgentXPCConnection] 0x16ba26410 activated
2025-10-30 11:06:14.155436-0700 0x55d5     Default     0x0                  143    0    securityd: [com.apple.securityd:SecurityAgentXPCConnection] contact didn't throw (0x16ba26410)

Is using the signed installer not enough to bypass this prompt ?

skinny avatar Oct 30 '25 18:10 skinny

Same result with public docker images and brew-installed 0.6.0 on macOS 26.0.1:

container registry login docker.io # -> Login succeeded

container build --tag test-java25 --file Dockerfile --no-cache .
...
Error: internalError: "error querying keychain for registry-1.docker.io (cause: "queryError("query failure: unhandledError(status: -25308)")")"

From system log:

2025-11-06 20:07:26.878384-0800 0x5b3f6    Error       0x0                  15927  0    container-core-images: [com.apple.container:ImagesHelper] handler for imagePull threw error internalError: "error querying keychain for registry-1.docker.io" (cause: "queryError("query failure: unhandledError(status: -25308)")")

From console, lots of connection failures, e.g., container-apiserver and container-core-images:

activating connection: mach=false listener=false peer=true name=com.apple.container.apiserver.peer[17159].0x9f08bc000
invalidated because the client process (pid 17159) either cancelled the connection or exited

Then finally for container-core-images:

error while checking integrity, denying access: CSSM Exception: -2147415840 CSSMERR_CSP_NO_USER_INTERACTION
handler for imagePull threw error internalError: "error querying keychain for registry-1.docker.io" (cause: "queryError("query failure: unhandledError(status: -25308)")")

It's unclear whether container registry login docker.io is setting anything in the keychain.

wti avatar Nov 07 '25 04:11 wti

Same result with signed package installer.

wti avatar Nov 07 '25 04:11 wti

FWIW, I notice an entry going in the keychain when using container registry login, however I get the same error mentioned:

Error: internalError: "error querying keychain for registry-1.docker.io (cause: "queryError("query failure: unhandledError(status: -25308)")")"

This is on Tahoe 26.1, with container 0.6.0.

U47 avatar Nov 07 '25 16:11 U47

I have managed to make this (somewhat) reliable by adding the credentials to the keychain myself :


security add-internet-password \
  -a "mycompreguser" \
  -s "mycompreg.azurecr.io" \
  -d "com.apple.container.registry" \
  -w "password" \
  -T "/usr/local/bin/container" \
  -T "/usr/local/libexec/container/plugins/container-core-images/bin/container-core-images" \
  -U /Library/Keychains/System.keychain  # (for system wide access)

Especially the line -T "/usr/local/libexec/container/plugins/container-core-images/bin/container-core-images" is important and is not added by the container cli. This plugin seems to be the actually binary accessing the credentials. Without that line I get the error but with it included, everything works so far.

As this project is still very new, and my experience with it limited this might totally be the wrong way of doing it, but this works for me based on trial and error

skinny avatar Nov 07 '25 16:11 skinny

I have managed to make this (somewhat) reliable by adding the credentials to the keychain myself : ...

This allowed me to pull an image once I deleted the entry in the login keychain, so it sure seems like @skinny has the smoking gun with the -T option to allow that program access to the key.

👏

U47 avatar Nov 07 '25 17:11 U47

fwiw, the keychain workaround failed for me. Running as the user who installed the container tool worked, while running via group permissions did not (I cleared the cache and metadata I could find, but there might be other factors).

wti avatar Nov 11 '25 20:11 wti

@wti I only tried this running as root and adding it to the System keychain. Running it as a non-root user you might want to experiment with adding it to the login keychain. The most important part I'm pretty sure about is having the container-core-images in the allowed list.

skinny avatar Nov 12 '25 01:11 skinny

For me this also ended up being a mix of versions of the container tool on my system, in this case one manually installed, and the version from homebrew:

which container
/usr/local/bin/container

After uninstalling the non-homebrew version with the script it comes with, the homebrew one was visible again:

container system stop
# Or -d to delete user data
uninstall-container.sh -k
which container
/opt/homebrew/bin/container

This also affects the keychain command since it needs the correct paths to the container binaries:

sudo security add-internet-password \
    -a "myusername" -s "registry.foo.com" -w "mypassword" \
    -d "com.apple.container.registry" \
    -T "$(brew --prefix container)/bin/container" \
    -T "$(brew --prefix container)/libexec/container-plugins/container-core-images/bin/container-core-images" \
    -U "/Library/Keychains/System.keychain"

A keychain prompt popped up in the UI even with sudo for me, so be aware of that. After asking for local network access container image pull with the private repo seems to be working for me at least.

adammillerio avatar Nov 14 '25 20:11 adammillerio

This is still a problem since 0.7.1 and the workaround in https://github.com/apple/container/issues/816#issuecomment-3503618765 still works.

farcaller avatar Dec 10 '25 08:12 farcaller

afaik in the current form, storing credentials to pull images is never going to work as long as the container-core-images plugin is not added to the trusted apps list together with the container binary. Changing this will require some minor changes in the containerization project.

@katiewasnothere @jglogan Not sure who to ping here, but is that the direction we want this to be solved ? Tempted to give this a try locally and create some PR's

Current plan :

Modify KeyChainHelper and KeyChainQuery (containerization) to allow an optional trusted application list to be passed int Modify Login to pass the container binary and (at least) the container-core-images plugin to the save method

skinny avatar Dec 11 '25 00:12 skinny

@skinny The keychain helper supports access groups today, but for this to work the application needs to be notarized with a restricted entitlement. This requires the container distribution to be packaged as a macOS application bundle which we're not set up for.

https://github.com/apple/containerization/pull/553

Regarding your container setup, if you just run container system start from a GUI login session and only run image push, image pull, etc from the GUI as well, do you see this issue?

Or are you running container system start and/or your registry-related commands in the background somehow (launch agent, or in an ssh login, for example)?

jglogan avatar Aug 04 '26 23:08 jglogan

@skinny The other question is, have you mixed usage of the apple/container release page distribution and the Homebrew install?

See #1310 for details.

jglogan avatar Aug 04 '26 23:08 jglogan