If your container spawns child processes (e.g., shell scripts), those children can become zombies when terminated. Docker defaults to PID 1 being your app, but PID 1 in Linux has special responsibilities—reaping orphaned children. Your app probably doesn’t do that.
The Solution: `tini`
FROM alpine:3.14
RUN apk add --no-cache tini
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["./my-app"]
Or simpler with Docker’s built-in:
docker run --init my-image
Key Takeaways
- Zombies consume PIDs. Too many will crash the container.
- Always use `–init` or `tini` if shelling out to subprocesses.
Discover more from C4: Container, Code, Cloud & Context
Subscribe to get the latest posts sent to your email.