A generic Docker compose health check for HTTP services with wget

Published on 2022-12-26 • Modified on 2022-12-26

This snippet shows how to create a Docker compose health check for HTTP services with wget. Usually, we can use CURL for these kinds of checks, eg:
curl --silent --fail localhost:9200/_cluster/health?wait_for_status=yellow&timeout=30s
But if CURL is not available, we can also use wget.


    healthcheck:
      test: ["CMD", "wget", "-qO-", "http://localhost:1080"]
      interval: 10s
      timeout: 5s
      retries: 5

 More on Stackoverflow   Read the doc  Random snippet