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.

  • Django rest project dockerfile
  • Docker for SQL Server 2012 Container support
  • In Docker swarm mode, is there a way to get managers' information from workers?
  • Pagecache and dirty pages in paused container
  • How about the docker run in virtul machine best practice?
  • How can I have shared assets (pictures, text documents, etc) between my Docker container and host system?
  • How I can inject artifact from AWS S3 inside Docker image?
  • Docker tool or feature to define per-project container aliases?
  • Docker Compose - [link/mount volume/volume_from] sharing data between containers, not using host
  • How to get docker container name in java code
  • Can docker containers share a directory amongst them
  • Is it possible to mount one Path to all container by default?
  • 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.