Can anyone suggest how can I setup NODE_ENV variable in dockerfile when running a node app.
Asked
Active
Viewed 3.3k times
15
-
1Possible duplicate of [How to pass environment variables to docker containers?](http://stackoverflow.com/questions/30494050/how-to-pass-environment-variables-to-docker-containers) – Thilo Mar 24 '17 at 06:00
1 Answers
34
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

Chris Overgaauw
- 78
- 1
- 7

opHASnoNAME
- 20,224
- 26
- 98
- 143
-
Can this be combined (does the runtime setting override the build-time setting)? – Thilo Mar 24 '17 at 11:49
-
3