[Bug]: after `container-apiserver` crashes (not a graceful stop), a still-running container is misreported as "stopped" and `container stop` silently no-ops on it
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
container run --name test-orphan -d alpine:3.22 sleep 300
# simulate a real crash, NOT `container system stop`
APIPID=$(ps aux | grep "container-apiserver start" | grep -v grep | awk '{print $2}')
kill -9 $APIPID
# apiserver auto-relaunches via launchd on the next client call
container list # empty — the live container is hidden
container list -a # shows test-orphan as "stopped" (incorrect)
container stop test-orphan # returns exit 0 ("success")
container kill test-orphan # errors: "no runtime client exists: container is stopped"
container delete test-orphan # this is the only command that actually stops it
# proof the process was alive the whole time despite "stopped"/stop-succeeded:
ps aux | grep container-runtime-linux # shows the real guest process, PPID 1, still running
# right up until `delete` is run
Problem description
Expected: after container-apiserver restarts following an abnormal termination, it should reconcile its persisted container records against the actual live OS processes (e.g. by container UUID/root path) before reporting status — a genuinely still-running container should be reported as running, and stop/kill should be able to act on it.
Actual: the still-running container's guest process (container-runtime-linux ... --uuid test-orphan) survives the apiserver crash untouched, reparented to PID 1. Once apiserver is relaunched, it incorrectly records this live container as stopped. As a result: - container list hides it entirely (default view only shows "running"). - container list -a shows the wrong state (stopped). - container stop test-orphan returns success but does nothing — the real process keeps running. - container kill test-orphan refuses with invalidState: "no runtime client exists: container is stopped". - Only container delete test-orphan actually terminates the orphaned process.
This is a same-user reliability/observability bug (not a privilege boundary issue), but it's a meaningful trust gap: an operator using stop as an incident-response action against a misbehaving container gets a false "success" while it keeps running with full network access.
Environment
- OS: macOS 26.4.1 (25E253)
- Xcode: N/A (not applicable to this issue)
- Container: Container CLI version 1.4.1 (build: release, commit: 9a8917c)
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Investigated this and opened two PRs, split by scope:
- #2292 — smallest fix:
container stopno longer silently claims success on an orphaned container (the most harmful part of the symptom — it was returning exit 0 while doing nothing to the still-live runtime process). Verified end-to-end locally. - #2293 — follow-up: fixes the underlying cause.
ContainersService.loadAtBoot()reconnects to any container whose runtime is still alive after an apiserver restart, socontainer list/stop/killall report and act on real state again, not just.stopped. Also fixes the same gap in theautoRemovereap path (a still-running--rmcontainer could otherwise get its bundle deleted out from under it). This one has an open design question for maintainers (eager vs. lazy reconciliation) noted in the PR description.
Both were tested against a real reproduction of the steps in this issue (SIGKILL container-apiserver, confirm the orphaned container-runtime-linux process, verify list/stop/kill/delete behavior before and after each fix) on macOS 26.4.1.