Skip to content

[Bug]: unable to delete container #1058

Closed
Closed

Description

@ptone

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 rm -f

Current behavior

container rm -f better-error
2026-01-15T19:30:03-0800 error com.apple.container: [ContainerCommands] failed to delete container better-error: internalError: "failed to delete container" (cause: "unknown: "Error Domain=NSCocoaErrorDomain Code=260 "The file “config.json” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/Users/ptone/Library/Application Support/com.apple.container/containers/better-error/config.json, NSURL=file:///Users/ptone/Library/Application%20Support/com.apple.container/containers/better-error/config.json, NSUnderlyingError=0x6000005c8390 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}"")
Error: internalError: "delete failed for one or more containers: ["better-error"]"

Expected behavior

I expected to delete the container

Environment

- OS: 

  System Version:	macOS 15.7.3 (24G419)
  Kernel Version:	Darwin 24.6.0

- Xcode: 
- Container:

Relevant log output

N/A

Code of Conduct

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

Activity

  1. added theissue type on Jan 16, 2026
  2. jglogan commented on Jan 16, 2026

    @jglogan
    Contributor

    @ptone What was your container run command? Can you provide repro steps?

  3. MarkOtzen commented on Jan 20, 2026

    @MarkOtzen

    I think I have the same issue, and I think I found a way to reproduce it.

    M2 Air (Tahoe 26.2, 0.7.1, release, commit 420be74), stumbled upon while trying to figure out why oraclelinux:10 would immediately exit (fumbled -it...):

    user@Mac ~> container run --name ora10 oraclelinux:10
    user@Mac ~> container inspect ora10 | jq '.[].status' -r
    stopped
    user@Mac ~> container exec ora10 sh
    Error: invalidState: "container ora10 is not running"
    user@Mac ~ [1]> container start ora10 && container exec ora10 sh
    ora10
    Error: internalError: "failed to create process in container" (cause: "internalError: "failed to create process 4aaf807e-440c-4be6-9dd7-381a3f8e64c1 in container ora10 (cause: "invalidState: "cannot exec: container is not running"")"")
    user@Mac ~ [1]> container rm ora10
    2026-01-20T23:36:29+0100 error com.apple.container: [ContainerCommands] failed to delete container ora10: internalError: "failed to delete container" (cause: "unknown: "Error Domain=NSCocoaErrorDomain Code=260 "The file “config.json” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/Users/user/Library/Application Support/com.apple.container/containers/ora10/config.json, NSURL=file:///Users/user/Library/Application%20Support/com.apple.container/containers/ora10/config.json, NSUnderlyingError=0x7ab0e0270 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}"")
    Error: internalError: "delete failed for one or more containers: ["ora10"]"
    

    Trying to exec on a stopped container results in the Error: invalidState: "container ora10 is not running" error message, but the error is different when the container was just started (and immediately stopped). inspect briefly reveals the status at that point as running:

    user@Mac ~> container start ora10 && container inspect ora10 | jq '.[].status' -r && sleep 0.1 && container inspect ora10 | jq '.[].status' -r
    ora10
    running
    stopped
    

    Running exec on a container (and letting it fail) during this brief running period reliably seems to result in the containers/<name> directory being lost.

  4. jglogan commented on Jan 21, 2026

    @jglogan
    Contributor

    @MarkOtzen Thanks for the report! I'll see if I can reproduce the container going missing via exec.

  5. jglogan commented on Jan 21, 2026

    @jglogan
    Contributor

    I see the same on main:

    % container run --name ora10 oraclelinux:10
    Warning! Running debug build. Performance may be degraded.
    
    % container exec ora10 sh  
    Warning! Running debug build. Performance may be degraded.
    Error: invalidState: "container ora10 is not running"
    
    % container start ora10 && container exec ora10 sh
    Warning! Running debug build. Performance may be degraded.
    ora10
    Warning! Running debug build. Performance may be degraded.
    Error: internalError: "failed to create process in container" (cause: "internalError: "failed to create process a00ce02f-3331-4016-84e0-cef23af523db in container ora10 (cause: "invalidState: "cannot exec: container is not running"")"")
    
    % container ls -a
    Warning! Running debug build. Performance may be degraded.
    ID     IMAGE                             OS     ARCH   STATE    ADDR  CPUS  MEMORY   STARTED
    ora10  docker.io/library/oraclelinux:10  linux  arm64  stopped        4     1024 MB  2026-01-21T18:00:50Z
    
    % container rm ora10
    Warning! Running debug build. Performance may be degraded.
    failed to delete container ora10: internalError: "failed to delete container" (cause: "unknown: "Error Domain=NSCocoaErrorDomain Code=260 "The file “config.json” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/Users/john/Library/Application Support/com.apple.container/containers/ora10/config.json, NSURL=file:///Users/john/Library/Application%20Support/com.apple.container/containers/ora10/config.json, NSUnderlyingError=0xc390345a0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}"")
    Error: internalError: "delete failed for one or more containers: ["ora10"]"
    
    % container system stop
    Warning! Running debug build. Performance may be degraded.
    2026-01-21T10:01:19-0800 info com.apple.container.cli: [ContainerCommands] checking if APIServer is alive
    2026-01-21T10:01:19-0800 info com.apple.container.cli: stopTimeoutSeconds=5 [ContainerCommands] stopping containers
    ora10
    2026-01-21T10:01:19-0800 info com.apple.container.cli: [ContainerCommands] waiting for containers to exit
    2026-01-21T10:01:19-0800 info com.apple.container.cli: label=gui/501/com.apple.container.apiserver [ContainerCommands] stopping service
    2026-01-21T10:01:19-0800 info com.apple.container.cli: label=gui/501/com.apple.container.container-network-vmnet.default [ContainerCommands] stopping service
    2026-01-21T10:01:19-0800 info com.apple.container.cli: label=gui/501/com.apple.container.container-core-images [ContainerCommands] stopping service
    2026-01-21T10:01:19-0800 info com.apple.container.cli: label=gui/501/com.apple.container.apiserver [ContainerCommands] stopping service
    
    % container system start
    Warning! Running debug build. Performance may be degraded.
    Verifying apiserver is running...
    
    % container ls -a
    Warning! Running debug build. Performance may be degraded.
    ID  IMAGE  OS  ARCH  STATE  ADDR  CPUS  MEMORY  STARTED
  6. jglogan commented on Jan 21, 2026

    @jglogan
    Contributor

    I think what's happening here is that the exec error is failing at a point in the code such that the cleanup being applied is the same as for run, where we'd want to remove the container if the workload startup (not the workload itself) fails for any reason.

    In the run case the in-memory container entity is never created, so there's no need to remove it, which means here, the on-disk container gets removed while the in-memory entity remains.

    Definitely a bug. Thanks again for filing the issue!

  7. ptone commented on Jan 22, 2026

    @ptone
    Author

    I don't have quite the repro steps, but I will say that my use-case does involve routinely exec'ing into a container to rejoin a tmux session in the container - the the above flow looks similar

  8. assigned and unassigned on Jan 22, 2026
  9. finagolfin commented on Jan 24, 2026

    @finagolfin

    Running exec on a container (and letting it fail) during this brief running period reliably seems to result in the containers/ directory being lost.

    I just saw a container disappear in a similar scenario, was pretty surprising.

  10. added this to the 2026-01 milestone on Jan 24, 2026
  11. added a commit that references this issue on Jan 27, 2026
    a57527e
  12. MarkOtzen commented on Jan 31, 2026

    @MarkOtzen

    Can no longer reproduce on current main (0.8.0-24-g113a6ec), thanks to everyone involved.

  13. added a commit that references this issue on Feb 4, 2026
    8b79ec5
  14. added a commit that references this issue on Feb 18, 2026
    61c0378
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions