0

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 service-foobar@example.com

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?

sheepiiHD
  • 392
  • 1
  • 14

1 Answers1

0

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 service-foobar@example.com

Build command

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

mysecret.txt contect:

YOURPASSWORD

Reference

Shmuel
  • 898
  • 4
  • 15