fix: docker monitor now uses container status

This commit is contained in:
yusing 2025-01-15 09:10:26 +08:00
parent 04e118c081
commit 26d259b952

View file

@ -29,6 +29,19 @@ func (mon *DockerHealthMonitor) CheckHealth() (result *health.HealthCheckResult,
if err != nil {
return mon.fallback.CheckHealth()
}
status := cont.State.Status
switch status {
case "dead", "exited", "paused", "restarting", "removing":
return &health.HealthCheckResult{
Healthy: false,
Detail: "container is " + status,
}, nil
case "created":
return &health.HealthCheckResult{
Healthy: false,
Detail: "container is not started",
}, nil
}
if cont.State.Health == nil {
return mon.fallback.CheckHealth()
}