title: Docker-Compose: healtcheck script (curl) but Service always (health: starting)
body: <p>I have the following <strong>docker-compose</strong></p>
  
  <pre><code>version: '2.1'
  services:
      myprogram-app:
          image: myprogram
          mem_limit: 1024m
          environment:
              - SPRING_PROFILES_ACTIVE=prod,swagger
              - EUREKA_CLIENT_SERVICE_URL_DEFAULTZONE=http://admin:$${jhipster.registry.password}@jhipster-registry:8761/eureka
              - SPRING_CLOUD_CONFIG_URI=http://admin:$${jhipster.registry.password}@jhipster-registry:8761/config
              - SPRING_DATASOURCE_URL=jdbc:postgresql://myprogram-postgresql:5432/myprogram
              - JHIPSTER_SLEEP=30
              - SPRING_DATA_ELASTICSEARCH_CLUSTER_NODES=myprogram-elasticsearch:9300
              - JHIPSTER_REGISTRY_PASSWORD=password
              - EMAIL_USERNAME
              - EMAIL_PASSWORD
          ports:
              - 8080:8080
          networks:
            - backend
          depends_on:
            jhipster-registry:
              condition: service_healthy
            myprogram-postgresql:
              condition: service_started
            myprogram-elasticsearch:
              condition: service_started
          restart: on-failure
      myprogram-postgresql:
          image: postgres:9.6.5
          mem_limit: 256m
          environment:
              - POSTGRES_USER=myprogram
              - POSTGRES_PASSWORD=myprogram
          networks:
            - backend
      myprogram-elasticsearch:
          image: elasticsearch:2.4.6
          mem_limit: 512m
          networks:
            - backend
      jhipster-registry:
          extends:
              file: jhipster-registry.yml
              service: jhipster-registry
          mem_limit: 512m
          ports:
              - 8761:8761
          networks:
            - backend
          healthcheck:
            test: ["CMD", "./isUp", "jhipster-registry:8761"]
            interval: 30s
            retries: 20
  networks:
    backend:
      driver: "bridge"
  </code></pre>
  
  <p>and the following script, in the same directory (project root):</p>
  
  <pre><code>echo Testing if $1 is UP
  
  http_code=$(curl -LI $1 -o /dev/null -w '%{http_code}\n' -s)
  
  if [ ${http_code} -eq 200 ]; then
      echo The service is UP and Running
      exit 0
  else
      echo The service is DOWN
      exit 1
  fi
  </code></pre>
  
  <p>The problem I'm facing is that, even after the jhipster-registry service has started, it continues to show me</p>
  
  <pre><code>CONTAINER ID        IMAGE                               COMMAND                  CREATED             STATUS                            PORTS                    NAMES
  8b16c572e0f2        jhipster/jhipster-registry:v3.2.4   "/bin/sh -c 'java   …"   6 minutes ago       Up 6 minutes (health: starting)   0.0.0.0:8761-&gt;8761/tcp   compose_jhipster-registry_1
  ed86d15ea485        elasticsearch:2.4.6                 "/docker-entrypoint.…"   6 minutes ago       Up 6 minutes                      9200/tcp, 9300/tcp       compose_myprogram-elasticsearch_1
  f268fa1a11f1        postgres:9.6.5                      "docker-entrypoint.s…"   6 minutes ago       Up 6 minutes                      5432/tcp                 compose_myprogram-postgresql_1
  </code></pre>
  
  <p>even if the service is up and running (I also did a log in on it).</p>
  
  <p>I did also a test, by executing the isUp command on my machine, and it works as expected:</p>
  
  <pre><code>izio@1z10:~/Desktop/WorkSpace/myprogram/compose$ ./isUp.sh localhost:8761
  Testing if localhost:8761 is UP
  The service is UP and Running
  izio@1z10:~/Desktop/WorkSpace/myprogram/compose$
  izio@1z10:~/Desktop/WorkSpace/myprogram/compose$ echo $?
  0
  izio@1z10:~/Desktop/WorkSpace/myprogram/compose$ 
  </code></pre>
  
  <p>Then finally, the registry service becomes unhealthy, having terminated the retries.</p>
  
  <pre><code>izio@1z10:~/Desktop/WorkSpace/myprogram/compose$  docker ps
  CONTAINER ID        IMAGE                               COMMAND                  CREATED             STATUS                      PORTS                    NAMES
  8b16c572e0f2        jhipster/jhipster-registry:v3.2.4   "/bin/sh -c 'java   …"   10 minutes ago      Up 10 minutes (unhealthy)   0.0.0.0:8761-&gt;8761/tcp   compose_jhipster-registry_1
  ed86d15ea485        elasticsearch:2.4.6                 "/docker-entrypoint.…"   10 minutes ago      Up 10 minutes               9200/tcp, 9300/tcp       compose_myprogram-elasticsearch_1
  f268fa1a11f1        postgres:9.6.5                      "docker-entrypoint.s…"   10 minutes ago      Up 10 minutes               5432/tcp                 compose_myprogram-postgresql_1
  </code></pre>
  
  <p>Can't get what is wrong with this healthcheck. How to fix it?</p>
  
  <p>Same stuff, using 127.0.0.1:8761</p>
  
  <pre><code>test: ["CMD", "./isUp", "127.0.0.1:8761"]
  </code></pre>
  
  <p>or localhost:8761</p>
  
  <pre><code>test: ["CMD", "./isUp", "localhost:8761"]
  </code></pre>