18

Can anyone suggest how can I setup NODE_ENV variable in dockerfile when running a node app.

1

1 Answer 1

37

There a two ways, while building the image or when running the container.

For builds:

Add to your Dockerfile

ENV NODE_ENV=whatEver

Or use build arguments if you don't want them to stick during runtime Docker build --build-args NODE_ENV whatEver

When running:

Run your container with "-e"

docker run -e NODE_ENV=whatever mycontainer
Sign up to request clarification or add additional context in comments.

2 Comments

Can this be combined (does the runtime setting override the build-time setting)?
yep it does override the image environment variable

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.