2

Working on Windows OS.

My node app using node-config isn't using docker environment variables. It's always using the default config.

I am using node-config custom environment variables as described here: https://github.com/lorenwest/node-config/wiki/Environment-Variables#custom-environment-variables

Everything is working well when running the app locally. The config by passes the default ones and takes the ones defined in my User variables when set.

Problem

  • I start a docker instance with all required Environment variables set.
  • I verify the env variables by running docker exec container_name env

However, the node app still uses the default config, instead of the environment variables.

I am not sure what setup I may be missing.

Sumatan
  • 106
  • 1
  • 7
  • sorry this isn't an answer to your problem, but I have this exact issue with Heroku. the custom-environment-variables don't override the default or production json files – NickW Jan 29 '19 at 13:03

1 Answers1

1

I'm a maintainer of node-config. I don't test with Docker or Heroku, but this most be an ordering problem. As long as the environment variables are set before require('config') happens, they will work-- at that point Docker or Heroku doesn't matter. The activity is happening inside the Node.js JavaScript engine at that point.

Try this simple test: Just before your line where you require('config'), use console.log or an equivalent to print out the environment variables that you care about. I expect you'll find that when it's not working it's because the environment variables are not set before node-config is loaded.

Mark Stosberg
  • 12,961
  • 6
  • 44
  • 49