title: Docker HEALTHCHECK fails in nodejs express application
body: <p>I have setup the new docker <code>HEALTHCHECK</code> command for a node / express container as follows</p>
  
  <pre><code>HEALTHCHECK --interval=5m --timeout=5s \
    CMD $ROOT_APPLICATION/healthcheck.sh localhost $PORT || exit 1
  </code></pre>
  
  <p>where the <code>healthcheck.sh</code> script do the following</p>
  
  <pre><code>function healthcheck () {
      pt=$2
      port=${pt:-"3000"}
      RES=$(curl -s http://$1:$2/status | jq '.status.online')
      if [ "$RES" == "true" ]; then
          return 0
      else
          return 1
      fi
  }
  healthcheck $@
  </code></pre>
  
  <p>The node api <code>/status</code> returns a <code>json</code> as follows</p>
  
  <pre><code>{
    "status": 
    {
       "online": true
    }
  }
  </code></pre>
  
  <p>I'm sure that the health check is correct since within the container I can do</p>
  
  <pre><code># $ROOT_APPLICATION/healthcheck.sh localhost $PORT
  # status=$?
  # [ $status -eq 0 ] &amp;&amp; echo "success" || echo "failed"
  success
  </code></pre>
  
  <p>Also calling manually the health check endpoint:</p>
  
  <pre><code># curl -s http://localhost:3000/ws/1.0/status| jq '.status.online'
  true
  </code></pre>
  
  <p>while if I check the container status I get a <code>unhealthy</code> state</p>
  
  <pre><code>CONTAINER ID        IMAGE                              COMMAND                  CREATED             STATUS                         PORTS                              NAMES
  d8539fa50a40        my_container         "node --max_old_sp..."   35 minutes ago      Up 35 minutes (unhealthy)      0.0.0.0:3000-3001-&gt;3000-3001/tcp   my_image
  </code></pre>
  
  <p><strong>[UPDATE]</strong></p>
  
  <p>Here is the output of <code>docker container inspect</code></p>
  
  <pre><code>    "FinishedAt": "0001-01-01T00:00:00Z",
      "Health": {
          "Status": "unhealthy",
          "FailingStreak": 9,
          "Log": [
              {
                  "Start": "2020-03-25T10:11:17.687207876Z",
                  "End": "2020-03-25T10:11:17.829283718Z",
                  "ExitCode": -1,
                  "Output": "rpc error: code = 2 desc = oci runtime error: exec failed: container_linux.go:247: starting container process caused \"invalid environment 'NODE_ID'\"\n"
  </code></pre>
  
  <p>To reproduce this issue you must define <code>docker-compose</code> yaml file having the <code>environment</code> variable <code>NODE_ID</code> unassigned:</p>
  
  <p>(minimal yaml file)</p>
  
  <pre><code>version: '2'
  services:
   my_service:
       environment:
          NODE_ID
          NODE_ENV=production
  </code></pre>