0

I am running comprehensive docker-compose file where I am trying to implement health-check mechanism.

Currently it looks like this

All services run in the same network

At the same time, I can curl the localhost:8088 from host machine terminal...

docker-compose -

version: '2.3'
services:
  # ... many more stuff above
  migrations:
    build:
      ...
    depends_on:
      ...
    volumes:
      - ...
    ports:
      - "8088:8088"
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://migrations:8088/" ] # throws 502 cannot connect
      interval: 30s
      timeout: 10s
      retries: 15

  someotherservice-whos-waiting-for-migration-service:
    build:
      ...
    depends_on:
      migrations:
        condition: service_healthy


  # ... many more services bellow

What can be wrong here. Thank you for your help in advance

For the record. Running the whole setup on M1 pro chip and colima for docker management.

Hope to understand why I can't curl my own url from the container to proceed with healthcheck

  • Can you show the logs with the 502? If that’s an HTTP error, 502 is a server-side failure. How do you know the problem is a connection failure? – Nick K9 Oct 28 '22 at 06:48
  • from-container$: curl -f http://localhost:8088/ curl: (22) The requested URL returned error: 502 cannotconnect – joycatcher Oct 31 '22 at 06:20
  • curl's `-f` or `--fail` argument reduces the output, making a failure harder to debug. I'd remove that, and instead add `--verbose` to get a better understanding of what's failing. Does the request reach the container's code? – Nick K9 Oct 31 '22 at 15:34

0 Answers0