Skip to content

Recover ghost containers on start#699

Merged
geodro merged 2 commits into
mainfrom
fix/ghost-container-recovery
Jun 30, 2026
Merged

Recover ghost containers on start#699
geodro merged 2 commits into
mainfrom
fix/ghost-container-recovery

Conversation

@geodro

@geodro geodro commented Jun 30, 2026

Copy link
Copy Markdown
Member

Fixes #698.

Problem

An unclean Podman Machine shutdown can desync libpod and c/storage: a container's DB entry survives (stuck Created) while its storage layer is gone, a "ghost". podman run --replace then fails and the unit never starts:

✗ redis: podman run lerd-redis: exit status 125: Error: getting container from store "<id>": container not known

The host podman client can't clear it (container not known against the missing layer), and lerd service reinstall doesn't help because its stop step uses the same host-side podman rm -f. The removal only succeeds inside the VM's rootful scope.

Change

On the service start pass, detect the getting container from store ...: container not known signature and purge the stuck-Created lerd-* containers inside the VM via podman machine ssh ... podman rm -f, then retry the start once. The purge is filtered to status=created, so running services are left alone; site data is host bind-mounted, so nothing is lost.

This mirrors the existing overlay-corruption heal. It is darwin-only (ghost_heal_darwin.go), with a no-op on Linux where native podman shares the container scope and a plain podman rm -f already reaches the record.

Notes

Not Podman version specific: the failure persisted across a 6 to 5 downgrade. The trigger is unclean VM shutdowns (host sleep/reboot without lerd quit).

The filter selectivity was verified live against a stuck-Created stand-in container: the heal targeted only that container and excluded all running services.

geodro added 2 commits June 30, 2026 17:49
An unclean Podman Machine shutdown can desync libpod and c/storage: a
container's DB entry survives (stuck Created) while its storage layer is
gone. `podman run --replace` then fails with:

  Error: getting container from store "<id>": container not known

and the unit never starts. The host podman client can't clear it
("container not known" against the missing layer); the removal only
succeeds inside the VM's rootful scope.

Detect that signature on the start pass and purge the stuck-Created
lerd-* containers in the VM via `podman machine ssh ... podman rm -f`,
then retry the start once. Targets status=created so running services
are untouched; site data is host bind-mounted, so nothing is lost.
Mirrors the existing overlay-corruption heal; darwin-only, no-op
elsewhere (native podman shares the container scope on Linux).
@geodro geodro merged commit ea07ef6 into main Jun 30, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Recover ghost containers (libpod DB entry with missing storage layer)

1 participant