How can I get environment variables of docker in node js?

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.

  • Logstash syslog input from docker container
  • How to set up a volume linked to S3 in Docker Cloud with AWS?
  • Docker add warfile to official Tomcat image
  • connect to container from a remote machine
  • Running Kubernetes Example on CoreOS, Part 1 not work
  • Elasticsearch 5.1 and Docker - How to get networking configured properly to reach Elasticsearch from the host
  • Docker run -d <private image> gives fatal. On other hosts it's ok?
  • How to connect cassandra which is in a docker image from outside the OS
  • Use dockerfile/mysql mysqld_safe mysqld from pid file error
  • Error running quickstart-camelservlet in OpenShift V3 with Fabric8 and Docker
  • VirtualBox memory exception - std::bad_alloc using TensorFlow and Docker
  • Docker error when uploading image
  • One Solution collect form web for “How can I get environment variables of docker in node js?”

    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"
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.