Ping endpoint working but docker healthcheck fails

My docker-compose.yml contains this:

    image: "traefik:v2.4"
    container_name: "traefik"
        - traefik.enable=true
        - traefik.constraint-label=traefik-public
        # ping
        -``) && Path(`/ping`)
      - --ping=true
      - --ping.entrypoint=websecure
      - --ping.manualRouting=true

This successfully exposes the ping endpoint under

Now if I want to implement automatic health checks via docker, the container always fail to deploy.
I tried it by adding the healthcheck directive to the docker-compose file:

  test: ["CMD", "traefik", "healthcheck", "--ping"]
  interval: 30s
  timeout: 3s
  retries: 30

Any ideas? Do I need to somehow tell the healthcheck command the path / subdomain where to reach ping endpoint?

please have a look on the recommended health check command. You can update the domain that points to Traefik instance and tune other parameters (internal, start_period) according to your needs.

      test: wget --quiet --tries=1 --spider || exit 1
      interval: 10s
      timeout: 1s
      retries: 3
      start_period: 10s

More details in that repo:


Thank you very much this works! Although I think this should be mentioned in the documentation as it suggests to use the CLI healthcheck command for healthchecks. Ping - Traefik

Glad to hear that it solved your issue. Thanks a lot for your feedback, we will update the documentation accordingly by adding examples of how to implement healthcheck correctly on K8S and Swarm :slight_smile:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.