Docker is "too verbose" in npm-cli-adduser

163 Views Asked by At

When my Dockerfile does the RUN command:

RUN npm-cli-adduser -r https://$PRIVATE_REPOSITORY_URL/repository/npm-read -u $PRIVATE_USERNAME -p "$PRIVATE_PASSWORD" -e [email protected]

It echos the private environment variables in the terminal. I would like to hide these variables, so that users who read the terminal do not see it.

Is this possible?

1

There are 1 best solutions below

0
On

You can use docker secrets, but you will need to store the variable in a file as far as i understand

Like this:

Dockerfile

FROM node:12

RUN --mount=type=secret,id=mysecret,dst=/foobar echo $(cat /foobar) >> test.txt
# In your case 
# RUN npm-cli-adduser -r https://$PRIVATE_REPOSITORY_URL/repository/npm-read -u $PRIVATE_USERNAME -p $(cat /foobar) -e [email protected]

Build command

docker build --secret id=mysecret,src=mysecret.txt . -t docker-debug

mysecret.txt contect:

YOURPASSWORD

Reference