My docker-compose.yml contains this:
services:
traefik:
image: "traefik:v2.4"
container_name: "traefik"
deploy:
labels:
- traefik.enable=true
- traefik.docker.network=traefik-public
- traefik.constraint-label=traefik-public
# ping
- traefik.http.routers.ping.rule=Host(`traefik.domain.com`) && Path(`/ping`)
- traefik.http.routers.ping.service=ping@internal
- traefik.http.routers.ping.tls.certresolver=le
- traefik.http.routers.ping.tls=true
[...]
command:
[...]
- --ping=true
- --ping.entrypoint=websecure
- --ping.manualRouting=true
This successfully exposes the ping endpoint under https://traefik.domain.com/ping
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:
healthcheck:
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?