fix(container): reap orphaned processes in Kit containers

This commit is contained in:
sam committed 2026-10-09 01:37:57 +11:00
1 parent 01b691142c
commit 6ecdd67262
1 file changed
+5
+5
View File
@@ -49,6 +49,10 @@ func StartKit(ctx context.Context, cli *client.Client, s KitSpec) (string, error
}
mounts = append(mounts, mount.Mount{Type: mount.TypeVolume, Source: v.Name, Target: v.Path})
}
// Docker's own init becomes PID 1 and reaps orphans. The worker is PID 1
// otherwise, and a detached hook that forks and exits leaves zombies the
// worker never waits on, until the container's PID table is exhausted.
hostInit := true
created, err := cli.ContainerCreate(ctx, client.ContainerCreateOptions{
Name: s.Name,
Config: &container.Config{
@@ -64,6 +68,7 @@ func StartKit(ctx context.Context, cli *client.Client, s KitSpec) (string, error
NetworkMode: container.NetworkMode(s.Network),
Binds: s.Binds,
Mounts: mounts,
Init: &hostInit,
},
})
if err != nil {