Skip to content

Commit 614e8e7

Browse files
author
William Blankenship
authored
Merge pull request #113 from Starefossen/docs/npm-verbose-output
Explain the npm verbosity in the node image
2 parents ea09683 + 95a5dd9 commit 614e8e7

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,51 @@ $ docker run -it --rm --name my-running-script -v "$PWD":/usr/src/app -w
5555
/usr/src/app node:4 node your-daemon-or-script.js
5656
```
5757

58+
## Verbosity
59+
60+
By default the Node.js Docker Image has npm log verbosity set to `info` instead
61+
of the default `warn`. This is because of the way Docker is isolated from the
62+
host operating system and you are not guaranteed to be able to retrieve the
63+
`npm-debug.log` file when npm fails.
64+
65+
When npm fails, it writes it's verbose log to a log file inside the container.
66+
If npm fails during an install when building a Docker Image with the `docker
67+
build` command, this log file will become inaccessible when Docker exits.
68+
69+
The Docker Working Group have chosen to be overly verbose during a build to
70+
provide an easy audit trail when install fails. If you prefer npm to be less
71+
verbose you can easily reset the verbosity of npm using the following
72+
techniques:
73+
74+
### Dockerfile
75+
76+
If you create your own `Dockerfile` which inherits from the `node` image you can
77+
simply use `ENV` to override `NPM_CONFIG_LOGLEVEL`.
78+
79+
```
80+
FROM node
81+
ENV NPM_CONFIG_LOGLEVEL warn
82+
...
83+
```
84+
85+
### Docker Run
86+
87+
If you run the node image using `docker run˙ you can use the `-e` flag to
88+
override `NPM_CONFIG_LOGLEVEL`.
89+
90+
```
91+
$ docker run -e NPM_CONFIG_LOGLEVEL=warn node ...
92+
```
93+
94+
### NPM run
95+
96+
If you are running npm commands you can use `--loglevel` to control the
97+
verbosity of the output.
98+
99+
```
100+
$ docker run node npm --loglevel=warn ...
101+
```
102+
58103
# Image Variants
59104

60105
The `node` images come in many flavors, each designed for a specific use case.

0 commit comments

Comments
 (0)