Docker Init Process: The Zombie Reaper

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`

Dockerfile4 lines
FROM alpine:3.14
RUN apk add --no-cache tini
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["./my-app"]

Or simpler with Docker’s built-in:

Bash1 line
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.

Written by

Nithin Mohan TK

Hello Namaste! 👋🏻 I'm an accomplished Enterprise Solution Architect & Engineering Leader with 20+ years of progressive experience architecting, building, and scaling transformative enterprise solutions. ⚜️ Solution Architect / AI & Cloud 📌 Galway, Ireland

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.