Traefik Healthcheck
Add a healthcheck to a Traefik service in Docker Compose.
1 min read
Updated
A Docker Compose service definition that gives Traefik a healthcheck, so dependent services wait until the reverse proxy is actually ready. The Compose file is below.
docker-compose.yaml
yaml
---
version: '3.9'
networks:
net:
driver: bridge
services:
traefik:
image: traefik:2.11.0
restart: unless-stopped
networks:
- net
ports:
- 80:80
- 443:443
healthcheck:
test: nc -zv `hostname` 80 >/dev/null 2>&1 || exit 1
interval: 10s
timeout: 1s
retries: 3
start_period: 10s