Skip to content

Commit c3e460d

Browse files
authored
Merge pull request #324 from nodejs/retrohacker-patch-1
Document init wrapper
2 parents 1a3363c + 5e45e63 commit c3e460d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

docs/BestPractices.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ Run with `NODE_ENV` set to `production`. This is the way you would pass in secre
77
```
88
-e "NODE_ENV=production"
99
```
10+
## Handling Kernel Signals
11+
12+
Node.js was not designed to run as PID 1 which leads to unexpected behaviour when running inside of Docker. For example, a Node.js process running as PID 1 will not respond to `SIGTERM` (`CTRL-C`) and similar signals. As of Docker 1.3, you can use the `--init` flag to wrap your Node.js process with a [lightweight init system](https://github.com/krallin/tini) that properly handles running as PID 1.
13+
14+
```
15+
docker run -it --init node
16+
```
17+
18+
You can also include tini [directly in your Dockerfile](https://github.com/krallin/tini#using-tini), ensuring your process is always started with an init wrapper.
1019

1120
## Non-root User
1221

0 commit comments

Comments
 (0)