CodePark/ questions / Node apps in Docker
START PRACTICINGPRACTICE
Backend question · Docker › Node apps in Docker

What does docker run --init myapp change?

It runs a small init process as PID 1 that forwards signals to your app and reaps zombie processes

--init adds Docker's built-in init process as PID 1, the first process in the container. This init is based on tini. Your command runs as its child.

The init process fixes two problems:

• It forwards signals, like SIGTERM, to your app.

• It
reaps zombie processes. These are finished child processes that nobody cleaned up.

Your app still needs its own SIGTERM handler if it wants to clean up before it exits.


"It re-initialises the container's writable layer on every start" is wrong. The word "init" here means an init process, not a reset of the file system.