Skip to content

Use docker-init -s to fix zombie containerd-shim processes in rootless mode - #580

Open
okhowang wants to merge 1 commit into
docker-library:masterfrom
okhowang:fix/docker-init-subreaper-rootless
Open

Use docker-init -s to fix zombie containerd-shim processes in rootless mode#580
okhowang wants to merge 1 commit into
docker-library:masterfrom
okhowang:fix/docker-init-subreaper-rootless

Conversation

@okhowang

Copy link
Copy Markdown

Description

dockerd-entrypoint.sh injects docker-init (tini) as PID 1 to work around zombie containerd-shim processes (docker-library/docker#318).

However, in rootless mode this does not actually take effect:

  • The rootless invocation of rootlesskit (--net=slirp4netns --mtu=1500 --disable-host-loopback --port-driver=builtin --copy-up=/etc --copy-up=/run ...) does not create a PID namespace (no --pidns) and does not enable --reaper. So rootlesskit does not act as a reaper.
  • As a result, docker-init is not PID 1 inside the rootless container. By default tini only reaps orphaned processes when it is PID 1, so containerd-shim processes exit and become zombies that are never reaped.

This fixes it by passing -s to docker-init, which makes tini register itself as a subreaper (PR_SET_CHILD_SUBREAPER) and thus reap orphaned descendants (such as containerd-shim) even when it is not PID 1.

set -- docker-init -s -- "$@"

This is safe for the non-rootless path as well: there docker-init is already PID 1, and -s is a harmless no-op in that case.

Diff

-	set -- docker-init -- "$@"
+	set -- docker-init -s -- "$@"

Related

Remarks

  • Affects docker:dind and docker:dind-rootless (both use this entrypoint).
  • No image rebuild required beyond regenerating the entrypoint; binaries are unchanged.

In rootless Docker (e.g. `docker:dind-rootless`), rootlesskit does not
create a PID namespace by default, so `docker-init` is not PID 1. tini
only reaps zombies when it is PID 1, so without `-s` the orphaned
`containerd-shim` processes described in docker-library#318 are
not reaped.

Pass `-s` to register `docker-init` as a subreaper, ensuring it reaps
orphaned descendant processes even when it is not PID 1. This is harmless
in non-rootless mode, where `docker-init` is already PID 1.
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.

1 participant