【发布时间】:2019-08-03 01:21:43
【问题描述】:
我遇到了一个问题。问题是 docker ps 命令将我的容器的健康状态始终显示为 unhealthy
我已经复制了那个问题并推送到 Github:https://github.com/korenb/docker-healthcheck-aspnetcore.git
我的步骤:
- 我在 aspnetcore 项目中配置了健康检查端点。路径是
/health - 然后我创建了 docker stuff 并将 HEALTHCHECK 属性设置为 official docs 中描述的
- 当我运行容器时,我看到它的状态永久不健康
检查命令为curl --fail http://localhost/health || exit 1
令我惊讶的是,如果我通过 docker exec <container> curl --fail http://localhost/health 运行该命令,那么它可以工作
我从docker inspect <container> 得到了一些日志,但我真的不知道出了什么问题。
{
"Status": "unhealthy",
"FailingStreak": 22,
"Log": [{
"Start": "2019-03-12T13:27:51.570474Z",
"End": "2019-03-12T13:27:51.6708017Z",
"ExitCode": -1,
"Output": "OCI runtime exec failed: exec failed: container_linux.go:344: starting container process caused \"exec: \\\"curl --fail http://localhost/health || exit 1\\\": stat curl --fail http://localhost/health || exit 1: no such file or directory\": unknown"
},
{
"Start": "2019-03-12T13:27:53.8550082Z",
"End": "2019-03-12T13:27:53.9882208Z",
"ExitCode": -1,
"Output": "OCI runtime exec failed: exec failed: container_linux.go:344: starting container process caused \"exec: \\\"curl --fail http://localhost/health || exit 1\\\": stat curl --fail http://localhost/health || exit 1: no such file or directory\": unknown"
}
]
}
我很绝望,所以我希望社区能帮助我解决问题
【问题讨论】:
标签: docker asp.net-core