Understanding health checks
Health checks verify that containers are operational by running periodic tests. Docker marks containers as:- healthy: Health check passed
- unhealthy: Health check failed after retries
- starting: Initial grace period before first check
Tailscale sidecar health check
Every Tailscale sidecar includes a health check that verifies Tailscale has connected to your Tailnet:Health check configuration
Command to execute. Returns exit code 0 for healthy, non-zero for unhealthy.
Time between health checks (e.g.,
30s, 1m, 2m).Maximum time to wait for the health check to complete.
Number of consecutive failures before marking as unhealthy.
Grace period before starting health checks. Allows container initialization.
Application health checks
Application containers also include health checks to verify the service is responding:Common health check patterns
- Process check
- HTTP endpoint
- Port check
- File check
Verify a process is running:
Dependency ordering
Thedepends_on directive ensures the application container waits for Tailscale to be healthy:
Without
condition: service_healthy, Docker would only wait for the Tailscale container to start, not for it to be ready.Monitoring health status
View health status
View health check logs
Troubleshooting unhealthy containers
Tailscale health check failing
Tailscale health check failing
Symptoms: Container shows as unhealthy, service not accessible on TailnetCheck the health endpoint:Common causes:
- Invalid auth key
- Tailscale not connected to Tailnet
- Network configuration issues
/dev/net/tundevice not available
Application health check failing
Application health check failing
Symptoms: Application container marked unhealthy, but Tailscale is healthyCheck the application:Common causes:
- Application failed to start
- Application crashed
- Health check command incorrect for this service
- Insufficient start_period for slow-starting services
Health check times out
Health check times out
Symptoms: Health check takes longer than the timeout valueSolution: Increase the timeout:
Custom health checks
For services with specific requirements, create custom health check scripts:healthcheck.sh
Health check best practices
Keep checks lightweight
Health checks run frequently. Avoid expensive operations like database queries.
Set appropriate intervals
Balance between quick failure detection and system load. 1 minute is typical.
Use adequate start periods
Allow slow-starting services time to initialize before health checks begin.
Test health checks
Run health check commands manually to verify they work correctly.
Advanced patterns
Multi-stage health checks
For services with initialization stages:healthcheck.sh
Conditional health checks
Disable health checks for debugging:Next steps
Troubleshooting
Solve common deployment issues
Docker Compose guide
Learn Docker Compose management