Hello and thanks for docker-node!
I have an issue with the printout from the container.
Step 10 : RUN make release-staging
---> Running in 53a9e21d6a66
[91mnpm[0m[91m [0m[91minfo it worked if it ends with[0m[91m ok
npm[0m[91m info using [email protected]
npm info using [email protected]
[0m[91mnpm[0m[91m [0m[91minfo[0m[91m [0m[91mok[0m[91m
[0mnpm install
[91mnpm[0m[91m [0m[91minfo[0m[91m [0m[91mit worked if it ends with[0m[91m ok
[0m[91mnpm[0m[91m [0m[91minfo[0m[91m [0m[91musing[0m[91m [email protected]
[0m[91mnpm[0m[91m [0m[91minfo[0m[91m [0m[91musing[0m[91m [email protected]
[0m[91mnpm[0m[91m [0m[91minfo[0m[91m [0m[91mattempt[0m[91m registry request try #1 at 1:22:04 PM
[0m[91mnpm[0m[91m [0m[91mhttp[0m[91m [0m[91mrequest[0m[91m GET https://registry.npmjs.org/babel-core
Before each [ there is an ESC character but I stripped that from the same since it's not shown in the output of the Jenkins console.
Can I disable the output from printing all these extra characters?
I tried to add this in the Dockerfile but it did not seem to help =-(
ENV NPM_COLOR false
Cheers,
-- mraxus
If this is the v6 image, then what you are most likely seeing is there is the output of npm@3's progress bar.
Try this:
ENV NPM_CONFIG_PROGRESS false
@chorrell is right, and while your at it, disable the spinner as well:
ENV NPM_CONFIG_PROGRESS false
ENV NPM_CONFIG_SPIN false
@chorrell and @Starefossen Thanks for your replies.
You are correct in the v6 image. I am running node:6.4.0.
However, the updated Dockerfile with both progress and spin had no effect.
Here is the content of the Dockerfile.
FROM node:6.4.0
ENV NPM_CONFIG_PROGRESS false
ENV NPM_CONFIG_SPIN false
WORKDIR /app
ARG REVISION
ARG BRANCH
ARG S3_STAGING_BUCKET
RUN apt-get update
RUN apt-get install -y python-pip
RUN pip install awscli
ADD . .
RUN chmod 755 *.sh
RUN make test <-- Here is the call to npm install
RUN make release-staging
RUN make build-production
CMD ["./release.sh"]
Is there anything else you need?
I also tried to include ENV NPM_CONFIG_COLOR false but without success. (I will stop testing that =p)
Should be said, before the npm commands, there are no problems with the std output.
As a simple test case, just doing something like this works when I tried it:
FROM node:6.4.0
ENV NPM_CONFIG_PROGRESS false
ENV NPM_CONFIG_SPIN false
WORKDIR /app
RUN npm install express
Are you running the npm install command via a make file or from a shell script that's called from a make file? If that's the case, you probably want to put the environment variables in either the make file or the shell/bash script to disable the progress bar:
export NPM_CONFIG_PROGRESS=false
export NPM_CONFIG_SPIN=false
I don't think the ENV instruction works in the same ay as export, meaning it doesn't make the variable available to bash sub-processes.
Another option would be to add a .npmrc file to your project with the npm settings you want and the file via a COPY:
COPY .npmrc /app
And in your .npmrc file:
progress=false
spin=false
Thanks for the additional suggestions @chorrel. However, none of the suggested ideas helped.
I searched for info regarding the codes generated by the npm command. This is the result:
http://jafrog.com/2013/11/23/colors-in-terminal.html
The format almost exactly matches my logs.
And continuing testing with building docker images locally, I noticed that the npm install is coloring certain lines. These match the pattern of the extra characters from my Jenkins logs.
I have continued to try to turn off the colors with both with:
ENV NPM_CONFIG_COLOR false.npmrc config.sh file withexport NPM_CONFIG_COLOR=false; npm install asyncNPM_CONFIG_COLOR=false npm install asyncEach time I still get the red coloring when viewing the docker console. When doing the same procedures locally, the output was not colored.
My only conclusion is that the configuration doesn't work for in the docker image. Please prove me wrong =)
@mraxus could you try to add --color false to all your npm commands. Like this:
npm --color false install async
@Starefossen Same results. I would believe this is very easily reproducible for anyone.
Dockerfile
FROM node:6.4.0
ENV NPM_CONFIG_COLOR false
WORKDIR /app
COPY run.sh /app
RUN bash run.sh
CMD ["node", "some_file.js"]
run.sh
#!/bin/bash
export NPM_CONFIG_COLOR=false
npm --color false install async
put them in a folder and run the command:
docker build .
I think it might have something to do with the output of the docker build command, and not npm. If I do something like this, no colours are displayed:
docker run -it --rm node:6.4.0 npm --color false install async
@chorrell Very interesting. Same result for me too.
But it have to be originating from npm somehow, since it still colors but only some part, not everything the same way. Frustrating, nonetheless.
Another option you might want to consider is
https://wiki.jenkins-ci.org/display/JENKINS/AnsiColor+Plugin (colorizes the
ANSI escapes in the Jenkins output). :smile:
@tianon If that works, it would be amazing. Will try it out, if the infra guys allows ;-) Thanks for the tip!
@chorrell, @Starefossen: I don't think I will spend more time on this, so do with this issue as you please. Thank you so much for the help anyways. Much appreciated!
I have the same problem, except I'm not using Jenkins, but rather Dockerhub where I don't have any control over things like plugins.
I would like to have this issue re-opened.
At this point it's not clear whether this is something that can be addressed in the Dockerfiles. Based on my experiments in https://github.com/nodejs/docker-node/issues/225#issuecomment-243558790, it seems like it's an issue with docker build or a combined issue with npm and docker build
Problem is that your Jenkins just does not support ANSI escape sequences in the console output. All output on STDERR in your Dockerfile is printed in red by docker build. So as mentioned by @tianon just use the AnsiColor+Plugin to fix this.
Closing since https://github.com/nodejs/docker-node/issues/225#issuecomment-243607952 addresses the issue for the OP.
I don't think we can do anything about the Dockerhub (if that's still an issue)
Hmm, I still have the exact same problem.
.npmrc:
color=false
progress=false
Dockerfile:
FROM node:8.1.4-alpine
COPY .npmrc .npmrc
# let's take a look at the config
RUN npm config ls -l
Now if I build the image like this:
docker build -t fancy-image-name .
Then the output is still showing colors even though the config says "color = false":
... truncated
Step 3/3 : RUN npm config ls -l
---> Running in 69e245ff6077
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm info ok
; cli configs
long = true
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/5.0.3 node/v8.1.4 linux x64"
; environment configs
loglevel = "info"
; project config /.npmrc
color = false
progress = false
; default values
... truncated
; color = true (overridden)
... truncated
; loglevel = "notice" (overridden)
... truncated
; long = false (overridden)
... truncated
; metrics-registry = null (overridden)
... truncated
; progress = true (overridden)
... truncated
; user-agent = "npm/{npm-version} node/{node-version} {platform} {arch}" (overridden)
The lines featuring npm info at the top are all in nice friendly red => they look like as if a cat walked over the keyboard when I look at the log in Jenkins...
I noticed that npm outputs progress to STDERR. Redirecting STDERR to STDOUT in my Dockerfile fixed the output problem:
e.g. change this:
RUN npm install
to this:
RUN npm install 2>&1
@zsteinkamp Wow that magically worked :o
Oh, this would be a really good thing to add to the docs!
Most helpful comment
I noticed that npm outputs progress to STDERR. Redirecting STDERR to STDOUT in my Dockerfile fixed the output problem:
e.g. change this:
RUN npm installto this:
RUN npm install 2>&1