Skip to content

[Bug]: Does not work with account with home directory in external drive over ssh, even after su into local user with local home directory #205

Open

Description

@mjc0608

I have done the following

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

Steps to reproduce

container system start in an ssh session

Current behavior

When ssh into the mac, container system start returns the following error:

Verifying apiserver is running...
Error: internalError: "failed to get a response from apiserver: interrupted: "XPC connection error: Connection invalid""

It looks like the GUI is a dependency, which is weird since this framework is supposed to run containers, and in a lot of use cases, people want to do this when using mac as a headless server.

Expected Behavior

The container should start as normal.

Environment

- OS: 15.3.1 (24D70)
- Xcode: xcode-select version 2409. xcode not installed
- Container: N/A

Code of Conduct

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

Activity

  1. makhov commented on Jun 15, 2025

    @makhov
    Contributor

    Could you please, show the apiserver logs? Try it again and then run container system logs --last 1m

  2. afbjorklund commented on Jun 15, 2025

    @afbjorklund

    I got the same error, Error: interrupted: "XPC connection error: Connection invalid"

    Nothing much in the logs:

    Filtering the log data using "subsystem == "com.apple.container""
    Timestamp                       Thread     Type        Activity             PID    TTL  
    --------------------------------------------------------------------------------------------------------------------
    Log      - Default:          0, Info:                0, Debug:             0, Error:          0, Fault:          0
    Activity - Create:           0, Transition:          0, Actions:           0
    

    Restarting the container daemon seems to have fixed it, container system restart

  3. makhov commented on Jun 15, 2025

    @makhov
    Contributor

    And if you increase the time interval is it anything in the logs?

  4. afbjorklund commented on Jun 15, 2025

    @afbjorklund
  5. afbjorklund commented on Jun 15, 2025

    @afbjorklund

    After rebooting (without GUI), it stopped working again.

    afb:~/ $ container run -it alpine true
    Error: interrupted: "XPC connection error: Connection invalid"

    But maybe this is the normal error, when it is not running?

    afb:~/ $ container system start
    Verifying apiserver is running...
    afb:~/ $ container run -it alpine true
    afb:~/ $ 

    And it was only the first time, when I got it also on start and stop.

  6. makhov commented on Jun 15, 2025

    @makhov
    Contributor

    Sorry, I'm not quite following. It's totally normal, that you get XPC connection error if apiserver is not running.
    The initial error is suspicious, because container system start starts the apiserver and then pings it to verify it's running. But starting apiserver may take some time, so it's possible, that ping is called when it's not yet running. If you could reproduce it, could you check apiserver after the system start by running any container, for example?

  7. afbjorklund commented on Jun 15, 2025

    @afbjorklund
  8. adityaramani commented on Jun 15, 2025

    @adityaramani
    Contributor

    Running containers should be possible without a GUI, and in a SSH session. The GitHub workflows on PRs exercise this functionality. As the other have pointed out you need to first run the container system start command, before trying to run any containers

    If you are able reproduce the behavior, could you share what this command returns?

    launchctl managername
    
  9. mjc0608 commented on Jun 16, 2025

    @mjc0608
    Author

    I think I know what happened. I logged in an LDAP-backed account and then su to a local service account. Then I ran the container system start command there. It fails with the error.

    If I (1) directly ssh into the local account or (2) ssh into a local account then su into another then everything works. So maybe this is an LDAP-binding issue.

    Also in both the failing case and successful case, launchctl managername shows Background.

  10. mjc0608 commented on Jun 16, 2025

    @mjc0608
    Author

    In the LDAP account, if I run container system start, it gets stuck forever. And container system logs returns log: Could not open local log store: Operation not permitted. I guess this is because some system directories are not created in my LDAP binding.

    But this does not explain why it does not work after su into a local admin where all there directories exist.

  11. mjc0608 commented on Jun 16, 2025

    @mjc0608
    Author

    If you believe this is not an issue, please close the thread.

  12. transitorykris commented on Jun 16, 2025

    @transitorykris

    I've found the same error with container system start on an account that has its user directory on an external unencrypted drive

  13. mjc0608 commented on Jun 16, 2025

    @mjc0608
    Author

    @transitorykris Did you try to login into that user and then su to a local user?

    My LDAP user also has external home directories. So this may be a home directory issue.

  14. 9 remaining items

  15. tjakobsson commented on Jun 18, 2025

    @tjakobsson

    For me, directly on a Mac mini with macOS 15.5, my main user has its home directory on an external drive - container system start does not work. Moving over to another account that has the home directory on the internal drive - it works.

    I don't know if that would be the same as this issue since I'm not using it over SSH. But it sounds like it could be.

  16. ephemer commented on Jun 20, 2025

    @ephemer

    I noticed this in another CLI application. I had to add Full Disk Access permission for it to work. (System Settings -> Privacy & Security -> Full Disk Access). Not sure if it'll work here, but wanted to mentioned it

  17. tjakobsson commented on Jun 20, 2025

    @tjakobsson

    I noticed this in another CLI application. I had to add Full Disk Access permission for it to work. (System Settings -> Privacy & Security -> Full Disk Access). Not sure if it'll work here, but wanted to mentioned it

    I tested this, it did not work unfortunately.

  18. ZhuangZzzi commented on Aug 3, 2025

    @ZhuangZzzi

    I am having the same error. New Mac.
    Environment

    • macOS Version: 26.0 (Build 25A5316i) - Beta
    • Architecture: arm64 (Apple Silicon M3 Ultra)
    • Container Version: 0.3.0 (both Homebrew and built from source)
    • Xcode Version: 16.4 (Build 16F6) and Xcode 26 beta
    • Home Directory: Located on external SSD at /Volumes/Disco/Users/
    • XPC connection error during container system start

    Here is the error:
    % container system start
    Verifying apiserver is running...
    Error: interrupted: "internalError: "failed to get a response from apiserver: interrupted: "XPC connection error: Connection invalid""
    Ensure container system service has been started with container system start."

    % launchctl managername
    Aqua

    % which container
    /usr/local/bin/container

    I tried building from source, using the signed release package, and using brew. All same error.
    The apiserver service fails to register with launchd.

    % launchctl list | grep -E "container|apiserver"
    449 0 com.apple.containermanagerd

    % launchctl print gui/$(id -u)/com.apple.container.apiserver
    Bad request.
    Could not find service "com.apple.container.apiserver" in domain for user gui: 501

    The apiserver binary executes successfully when run directly from a local build: container-apiserver --help works

    Like I said, new Mac. The only "jank" in my setup is having my home dir on external ssd. Any update? or something I can run to create a new lead?

  19. mortbauer commented on Oct 7, 2025

    @mortbauer

    I'm trying to run it as a daemon with a daemon user with home directory at /var/container and face the same issue, no external ssd, new macos mini m4

  20. outcoldman commented on Nov 4, 2025

    @outcoldman

    Have similar issue, and it is pretty easy to reproduce actually without having a user home directory not on internal drive.

    I have NVMe RAID0 mounted as /Volumes/DATA, where I wanted to move all the containers/images.

    I tried first to do ln -s /Volumes/DATA/Container ~/Library/Application\ Support/com.apple.container to see if it will be possible to just trick the system. It failed to start.

    But I noticed the option container system start --app-root /Volumes/DATA/Container, so I gave it a try, and got the same issue

    container system start -a /Volumes/DATA/Container 
    Verifying apiserver is running...
    Error: interrupted: "internalError: "failed to get a response from apiserver: interrupted: "XPC connection error: Connection invalid""
    Ensure container system service has been started with `container system start`."
    
  21. wti commented on Nov 15, 2025

    @wti

    fwiw: In my testing, the container process call to launchctl to start the apiserver fails when the apiserver.plist is created on an external drive (reproduced on the command line). Configuring the approot to use the internal drive enables the apiserver to start and serve some xpc requests. However later services required to run a container fail (still investigating), though approot appears to be correctly obtained from the apiserver.

  22. jglogan commented on Apr 5, 2026

    @jglogan
    Contributor

    @wti that's my observation as well.

    @adityaramani FYI

    I don't know if there are any other issues behind the plist issue, but I think the thing for the interested developer to try out is to locate all plists that we launch from on the system volume.

    I think it might be helpful for diagnostic purposes for the various managers to locate plists with all the other resource-specific infomation. Right now the PluginLoader writes the plist to pluginStateRoot but we could have it also write to, say, a common directory on the system volume that holds all the plists that we actually launch from. We could have system start create that as a temp directory and then plumb that down to the API server and plugins as CONTAINER_LAUNCH_ROOT just like our other base directories.

  23. robbiemu commented on Jun 23, 2026

    @robbiemu

    I can reproduce the apparent GUI-session dependency in a more controlled setup.

    This is not an external-home-directory issue and does not depend on SSH. The affected account has a normal local home directory on the internal disk.

    Summary

    container works:

    • for root from a headless system LaunchDaemon;
    • for an unprivileged service account after that account has an Aqua session.

    It does not work for that same unprivileged account when it is run headlessly through a system LaunchDaemon with UserName=<service-account>.

    The failure is permanent, not a startup race: container system start creates the per-user apiserver.plist, but com.apple.container.apiserver is never registered in a usable bootstrap domain, and all subsequent CLI calls fail with XPC connection error: Connection invalid.

    This prevents using Apple Container as an unattended service runtime owned by a non-admin service account.

    Environment

    • macOS: <paste sw_vers output>
    • Hardware: Apple silicon Mac mini
    • Container version: <paste container version output>
    • Install location: /usr/local
    • Service account: standard, non-admin local user with home at /Users/gitlab
    • The account is not logged in during the failing test.
    • The account home directory is on the internal system volume.

    Reproduction

    Create a standard local user, for example gitlab, with a normal local home directory.

    Install a system LaunchDaemon that runs only:

    <key>UserName</key>
    <string>gitlab</string>
    
    <key>ProgramArguments</key>
    <array>
      <string>/bin/zsh</string>
      <string>-c</string>
      <string>
        /usr/local/bin/container system start --timeout 60
        /usr/local/bin/container list --all
      </string>
    </array>

    Load it in the system domain while gitlab is not logged in.

    Actual behavior

    The job runs with the expected Unix identity:

    UID=507
    EUID=507
    USER=gitlab
    HOME=/Users/gitlab
    PPID=1
    

    But container system start fails:

    Launching container-apiserver...
    Testing access to container-apiserver...
    Error: internalError: "failed to get a response from apiserver: interrupted: "XPC connection error: Connection invalid""
    

    Retrying container list --all repeatedly continues to fail with the same error.

    Unified logs show the CLI attempting the Mach lookup and failing:

    activating connection: mach=true ... name=com.apple.container.apiserver
    failed to do a bootstrap look-up: xpc_error=[3: No such process]
    invalidated after a failed init
    

    After this failure:

    launchctl print user/507/com.apple.container.apiserver
    

    shows that the service is not registered.

    There is no gui/507 bootstrap domain while the account is logged out, and no gitlab-owned container-apiserver process appears.

    Control experiments

    1. Root, headless, system LaunchDaemon: works

    A temporary root-owned system LaunchDaemon running:

    container system start
    container list --all
    

    works without any GUI login.

    container system status reports:

    status             running
    appRoot            /var/root/Library/Application Support/com.apple.container/
    

    A root-owned container-apiserver is registered in the system domain, and container list --all succeeds.

    2. Same gitlab account in an Aqua session: works

    After fast-user-switching into gitlab and running:

    container system start
    container list --all
    

    the account gets a gui/507 bootstrap domain, com.apple.container.apiserver appears there, and a gitlab-owned apiserver process starts.

    container list --all succeeds, and creating/removing a disposable native volume succeeds.

    After logging gitlab out, gui/507 disappears. Re-running the original UserName=gitlab system LaunchDaemon reproduces the XPC failure.

    Generated plist comparison

    The generated apiserver plists for the working interactive user and the failing service account are structurally identical except for app-root path and ownership.

    Both include:

    Label: com.apple.container.apiserver
    MachServices: com.apple.container.apiserver
    ProgramArguments: /usr/local/bin/container-apiserver start
    RunAtLoad: true
    LimitLoadToSessionType: Aqua, Background, System
    

    The service-account plist is generated correctly under:

    /Users/gitlab/Library/Application Support/com.apple.container/apiserver/apiserver.plist
    

    but it is never registered in user/507 and cannot be reached by the CLI.

    Expected behavior

    One of these should be supported:

    1. container system start should be able to bootstrap and use a per-user apiserver from a noninteractive system LaunchDaemon running as that user; or

    2. the project should document that per-user Apple Container runtimes require an Aqua login session, and provide a supported headless/service-account mode for unattended workloads.

    The current behavior leaves an awkward gap:

    • root works headlessly;
    • an interactive user works;
    • a non-admin, headless service account does not.

    That makes it difficult to run an unattended service with a dedicated least-privilege account.

    Happy to provide the minimal plist, full launchctl print output, and filtered unified logs if useful.

  24. wti commented on Jun 28, 2026

    @wti

    FYI, my workaround circa April '26 was to run the service initially as a internal-drive user, and then edit the plist to remove the Aqua session requirement. Then I can run the container by changing only the shell user when executing the command (the Aqua session is still pinned to the external-drive user). This still means running container as the internal-drive user, but avoids the need to logout the external-driver user and login the internal-drive user (and stop whatever else the external user on the Aqua/GUI session is doing).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions