1

I am using docker to run node server.js
In terminal, I execute docker run --env-file .env -p 8080:8080 -d node-web-app and I am trying to use process.env in server.js to get environment variables in docker
However, RangeError: Invalid status code: 0 occurs.
How can I fix it and get the environment variables in docker?
Thanks in advance.

1
  • check if the variable is correctly set in docker container! use this to connecto to bash and then check for variable. Commented Nov 26, 2016 at 21:17

1 Answer 1

1

That error is related to your HTTP handler, not env variables. Make sure you send a valid response.

 res.send('OK')
 res.send(JSON.stringify(process.env));


docker run -e "test=1" -e "testb=2"
Sign up to request clarification or add additional context in comments.

Comments

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.