Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm install shows colors during install on Docker Hub

Tags:

npm

docker

I'm trying to perform npm install in a Dockerfile, but even when supposedly disabling the colors, color codes still seem to appear in the Dockerhub build logs.

What might I be doing wrong?

You can find the Dockerfile with the build details on Docker Hub: https://hub.docker.com/r/amcsi/szeremi/builds/btk4utf3whezxqhnbzpkhyw/

Dockerfile:

FROM node
MAINTAINER  Attila Szeremi <[email protected]>
RUN mkdir /src
WORKDIR /src
RUN cd /src
# Copy just the package.json file file as a cache step.
COPY package.json /src/package.json
# Disable progress so npm would install faster.
# Disable colors, because Dockerhub can't display them.
# Install NPM packages excluding the dev dependencies.
RUN npm set progress=false && npm set color=false && npm install --production

COPY . .
RUN npm run build
EXPOSE  8080
CMD ["npm", "run", "start"]

Sample of the build script's output:

Step 3 : WORKDIR /src
 ---> Running in 4a8ec4902bee
 ---> ce66cec7780b
Removing intermediate container 4a8ec4902bee
Step 4 : RUN cd /src
 ---> Running in 561c6d10cdb8
 ---> c12b27e7c01a
Removing intermediate container 561c6d10cdb8
Step 5 : COPY package.json /src/package.json
 ---> ebbb940c8911
Removing intermediate container c39be008ad46
Step 6 : RUN npm set progress=false && npm set color=false && npm install --production
 ---> Running in c9ebee32f367
[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[91mconfig[0m[91m set "progress" "false"
[0m[91mnpm[0m[91m [0m[91minfo[0m[91m ok 
[0m[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[91mconfig[0m[91m set "color" "false"
[0m[91mnpm[0m[91m [0m[91minfo[0m[91m [0m[91mok[0m[91m 
[0m[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]
like image 783
Attila Szeremi Avatar asked Jan 28 '16 22:01

Attila Szeremi


People also ask

What is Workdir in Dockerfile?

The WORKDIR command is used to define the working directory of a Docker container at any given time. The command is specified in the Dockerfile. Any RUN , CMD , ADD , COPY , or ENTRYPOINT command will be executed in the specified working directory.

How do I update automated repositories in Docker Hub?

From the Repositories page, click into a repository, and click the Builds tab. Click Configure automated builds to edit the repository's build settings. In the Build Rules section, locate the branch or tag you no longer want to automatically build. Click the autobuild toggle next to the configuration line.


1 Answers

The solution that worked for me was npm install 2>&1 which I found here: https://github.com/nodejs/docker-node/issues/225

like image 97
Bwyss Avatar answered Nov 15 '22 08:11

Bwyss