docker - 带有网络核心的 Docker Healcheck
问题描述
我遇到了一个问题。问题是该docker ps
命令将我的容器的健康状态始终显示为不健康
我已经复制了这个问题并推送到 Github:https ://github.com/korenb/docker-healthcheck-aspnetcore.git
我的步骤:
- 我在 aspnetcore 项目中配置了 healthcheck 端点。路径是
/health
- 然后我创建了 docker stuff 并按照官方文档中的描述设置了 HEALTHCHECK属性
- 当我运行容器时,我看到它的状态永久不健康
检查命令是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"
}
]
}
我很绝望,所以我希望社区能帮助我找出问题所在
解决方案
细节决定成败
我从OCI 运行时 exec failed: exec failed: (...) executable file not found in $PATH": unknown that command must be clean of any引号周围发现。
所以在 dockerfile 我替换了这个
HEALTHCHECK ... CMD ["curl --fail http://localhost/health || exit 1"]
这样
HEALTHCHECK ... CMD curl --fail http://localhost/health || exit 1
推荐阅读
- c# - 令牌中的自定义属性
- django - 在前端使用 reactjs 时是否需要使用 django 表单?
- r - 将数据集中的一组数据更改为不同的条目
- sql - 多个 NVL 参数
- java - 当我使用带有文本的文本文件(如下所示)运行此代码时,为什么它会给我一个 java.util.InputMismatchException
- javascript - 模板剑道网格Jquery中的Concat变量
- c - 理解不同C指针赋值的区别
- angular - 为排序标题事件角材质创建模拟
- bixby - “表单”和“布局”可以一起用于渲染输入视图吗?
- vue.js - 如何将 CodePen 拆分为 webpacked 组件?