title: Docker nginx healthcheck failing but script works when healthcheck not defined
body: <p>We have an issue where we have defined a docker healthcheck for an Nginx container in a docker-compose file. The healthcheck just runs a node js script which performs an https api call on the endpoint of the nginx container. 
  The healthcheck fails due to http timeout. If we exec inside the nginx container and run 'node nginxcheck.js' we get the same timeout. The application itself is run in a single node swarm ( docker stack deploy) but its the same even if we just run docker-compose up</p>
  
  <p>The strange thing is when the healthcheck is not defined in docker-compose then we can exec in and run the script and it passes fine. Again its just performing an https request on itself. So we know the script is OK and it works. </p>
  
  <p>Its as if defining the healthcheck itself is obstructing the script. Indeed even trying to contact the endpoint from outside the host fails but all works fine when there is no healthcheck. We tried defining the healthcheck in the Dockerfile but it makes no difference. Below is a snippet of how we've defined it </p>
  
  <pre><code>  nginx:
      image: nginxdev
      deploy:
        replicas: 1
        restart_policy:
        condition: on-failure
      restart: always
      healthcheck:
       test: node ./etc/nginx/nginxcheck.js
       interval: 120s
       timeout: 60s
       retries: 1
      depends_on:
       - web
      ports:
        - "443:443"
      links:
        - web
      volumes:
        - ./certs:/etc/nginx/certs
  </code></pre>