Skip to content

[Bug]: Container auto deletes when we stop a container and start the same container within few milliseconds. #833

Closed

Description

@theetherGit

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

Please watch the video:

error-on-start-after-stopping-container.mov

Current behavior

  • Start a container
container start redis
  • Stop the container
container stop redis
  • Start same container within a second
container start redis

Here you will get Error: internalError: "failed to bootstrap container" (cause: "internalError: "failed to bootstrap container redis (cause: "invalidState: "container expected to be in created state, got: shuttingDown"")"")
And it automatically removes the container from the system.

Expected behavior

  • Start a container
container start redis
  • Stop the container
container stop redis
  • Start same container within a second
container start redis

with no errors or safe fallback [Last version I used was 0.4.1, and it works fine].

Environment

- OS: macOS 26.0.1 (25A362)
- Xcode: Version 26.0 (17A5276g)
- Container: 0.6.0

Relevant log output

Error Output:
Error: internalError: "failed to bootstrap container" (cause: "internalError: "failed to bootstrap container redis (cause: "invalidState: "container expected to be in created state, got: shuttingDown"")"")

Container System Logs (container system logs):

container-runtime-linux: [com.apple.container:RuntimeLinuxHelper] starting start [uuid=redis]
2025-11-03 15:07:16.912561+0530 0x3495b    Info        0x0                  20755  0    container-runtime-linux: [com.apple.container:RuntimeLinuxHelper] configuring XPC server [uuid=redis]
2025-11-03 15:07:16.912799+0530 0x3495b    Info        0x0                  20755  0    container-runtime-linux: [com.apple.container:RuntimeLinuxHelper] starting XPC server [uuid=redis]
2025-11-03 15:07:16.913228+0530 0x3496a    Info        0x0                  20755  0    container-runtime-linux: [com.apple.container:RuntimeLinuxHelper] `createEndpoint` xpc handler [uuid=redis]
2025-11-03 15:07:16.913521+0530 0x3496a    Info        0x0                  20755  0    container-runtime-linux: [com.apple.container:RuntimeLinuxHelper] `bootstrap` xpc handler [uuid=redis]
2025-11-03 15:07:16.917368+0530 0x3496c    Info        0x0                  7903   0    container-network-vmnet: [com.apple.container:NetworkVmnetHelper] allocated attachment [address=192.168.64.19/24] [gateway=192.168.64.1] [hostname=redis] [id=default]
2025-11-03 15:07:16.917587+0530 0x3495b    Info        0x0                  20755  0    container-runtime-linux: [com.apple.container:RuntimeLinuxHelper] creating NATNetworkInterface with network reference [uuid=redis]
2025-11-03 15:07:17.358438+0530 0x3495b    Info        0x0                  20755  0    container-runtime-linux: [com.apple.container:RuntimeLinuxHelper] `startProcess` xpc handler [uuid=redis]
2025-11-03 15:07:17.466438+0530 0x3469e    Info        0x0                  7894   0    container-apiserver: [com.apple.container:APIServer] registering container redis with exit monitor
2025-11-03 15:07:17.466587+0530 0x3495b    Info        0x0                  20755  0    container-runtime-linux: [com.apple.container:RuntimeLinuxHelper] `state` xpc handler [uuid=redis]
2025-11-03 15:07:17.467322+0530 0x3496b    Info        0x0                  20755  0    container-runtime-linux: [com.apple.container:RuntimeLinuxHelper] `wait` xpc handler [uuid=redis]
2025-11-03 15:07:19.197011+0530 0x3496a    Info        0x0                  20755  0    container-runtime-linux: [com.apple.container:RuntimeLinuxHelper] `stop` xpc handler [uuid=redis]
2025-11-03 15:07:19.311404+0530 0x3496a    Error       0x0                  20755  0    container-runtime-linux: [com.apple.container:RuntimeLinuxHelper] process deletion [id=redis] [uuid=redis] [error=internal error (13): unknown error processing request]
2025-11-03 15:07:19.318388+0530 0x3495b    Info        0x0                  20755  0    container-runtime-linux: [com.apple.container:RuntimeLinuxHelper] init process exited with: ExitStatus(exitCode: 0, exitedAt: 2025-11-03 09:37:19 +0000) [uuid=redis]
2025-11-03 15:07:19.392325+0530 0x349e8    Info        0x0                  20755  0    container-runtime-linux: [com.apple.container:RuntimeLinuxHelper] closing forwarders [uuid=redis]
2025-11-03 15:07:19.392326+0530 0x349e8    Info        0x0                  20755  0    container-runtime-linux: [com.apple.container:RuntimeLinuxHelper] closed forwarders [uuid=redis]
2025-11-03 15:07:19.392639+0530 0x34750    Info        0x0                  7903   0    container-network-vmnet: [com.apple.container:NetworkVmnetHelper] released attachments [id=default] [hostname=redis]
2025-11-03 15:07:19.397007+0530 0x345fa    Info        0x0                  7894   0    container-apiserver: [com.apple.container:APIServer] Shutting down sandbox service for redis
2025-11-03 15:07:19.397250+0530 0x3496b    Info        0x0                  20755  0    container-runtime-linux: [com.apple.container:RuntimeLinuxHelper] `shutdown` xpc handler [uuid=redis]
2025-11-03 15:07:20.820642+0530 0x349e8    Info        0x0                  20755  0    container-runtime-linux: [com.apple.container:RuntimeLinuxHelper] `createEndpoint` xpc handler [uuid=redis]
2025-11-03 15:07:20.821021+0530 0x3496b    Info        0x0                  20755  0    container-runtime-linux: [com.apple.container:RuntimeLinuxHelper] `bootstrap` xpc handler [uuid=redis]
2025-11-03 15:07:20.821794+0530 0x3496b    Error       0x0                  20755  0    container-runtime-linux: [com.apple.container:RuntimeLinuxHelper] handler for com.apple.container.sandbox/bootstrap threw error invalidState: "container expected to be in created state, got: shuttingDown" [uuid=redis]
2025-11-03 15:07:20.831084+0530 0x3469e    Error       0x0                  7894   0    container-apiserver: [com.apple.container:APIServer] WaitHandler for redis threw error internalError: "failed to wait for process redis in container redis" (cause: "interrupted: "XPC connection error: Connection interrupted"")
2025-11-03 15:07:20.903142+0530 0x346a0    Error       0x0                  7894   0    container-apiserver: [com.apple.container:APIServer] handler for containerBootstrap threw error internalError: "failed to bootstrap container redis" (cause: "invalidState: "container expected to be in created state, got: shuttingDown"")
2025-11-03 15:07:20.903147+0530 0x3469f    Info        0x0                  7894   0    container-apiserver: [com.apple.container:APIServer] Handling container redis exit. Code ExitStatus(exitCode: -1, exitedAt: 2025-11-03 09:37:20 +0000)
2025-11-03 15:07:20.903712+0530 0x3469e    Error       0x0                  7894   0    container-apiserver: [com.apple.container:APIServer] handler for containerStop threw error notFound: "container with ID redis not found"

Code of Conduct

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

Activity

  1. added theissue type on Nov 3, 2025
  2. changed the title [-][Bug]: Container auto deletes when we stop a container and start the same container in within few milliseconds.[/-] [+][Bug]: Container auto deletes when we stop a container and start the same container within few milliseconds.[/+] on Nov 3, 2025
  3. Ronitsabhaya75 commented on Nov 3, 2025

    @Ronitsabhaya75
    Contributor

    Hi @theetherGit, I've been looking at video and found this

    this is what i think happening here:

    • You run container stop redis → state changes to .shuttingDown
    • The shutdown process starts a 5-second delay before actually exiting
    • You run container start redis quickly (within that 5-second window)
    • The start command tries to bootstrap, but state is still .shuttingDown
    • Bootstrap fails with the exact error you're seeing
    • The error triggers auto-removal of the container

    i think way we can improve here is

    • Adding state check/wait in the start command - Before attempting to start, and then check if container is in .shuttingDown state and wait for it to complete

    let me know if this make sense

  4. self-assigned this
    on Nov 3, 2025
  5. dcantah commented on Nov 3, 2025

    @dcantah
    Contributor

    Can fix, thanks

  6. theetherGit commented on Nov 4, 2025

    @theetherGit
    Author

    @Ronitsabhaya75

    The shutdown process starts a 5-second delay before actually exiting

    I didn't knew about 5 second delay and shuttingDown state is the reason for the auto removal of container.

    @dcantah & @realrajaryan Thanks

  7. added a commit that references this issue on Jan 1, 2026
    edadf15
  8. added a commit that references this issue on Jan 8, 2026
    d584565
  9. added 3 commits that reference this issue on Jan 20, 2026
    1559e6d
    0099292
    94ba456
  10. added a commit that references this issue on Jan 27, 2026
    fdd909f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions