Home > Mobile >  Using ARG in my Dockerfile but still getting "Failed to replace env in config" when runnin
Using ARG in my Dockerfile but still getting "Failed to replace env in config" when runnin

Time:06-09

I have this file (.npmrc.docker)

//registry.npmjs.org/:_authToken=${NPM_TOKEN}

And in my Docker file I have

ARG NPM_TOKEN
RUN mv .npmrc.docker .npmrc
RUN yarn install

However when I run my Docker build with

NPM_TOKEN=mySecretToken docker build .

I get this error

#41 0.710 error An unexpected error occurred: "Failed to replace env in config: ${NPM_TOKEN}".

What’s the proper way to pass an environment variable into my Docker build?

CodePudding user response:

docker build --build-arg NPM_TOKEN=mySecretToken . should do the job

Ref here

  • Related