docker - Docker swarm 堆栈文件运行状况检查命令无法按预期工作
问题描述
我遇到了以下问题:
容器使用以下运行状况检查配置运行(test
有问题)
healthcheck:
test: ["CMD-SHELL", "curl -s -X GET http://127.0.0.1:5000/actuator/health", "|", "grep 'UP'"]
interval: 30s
timeout: 3s
retries: 3
start_period: 10s
在运行时,我看到只考虑了 healthcheck 测试命令 ( curl -s -X GET http://127.0.0.1:5000/actuator/health
) 的第一部分。端点以状态回答:Down,但通过了健康检查 - "Status": "healthy"
:
docker inspect 1f074dc72c6d | grep -i -A 10 health
"Health": {
"Status": "healthy",
"FailingStreak": 0,
"Log": [
{
"Start": "2019-12-10T11:37:46.215783033Z",
"End": "2019-12-10T11:37:46.315844469Z",
"ExitCode": 0,
"Output": "{\"status\": \"DOWN\"}"
},
{
"Start": "2019-12-10T11:38:16.346253717Z",
--
"Healthcheck": {
"Test": [
"CMD-SHELL",
"curl -s -X GET http://127.0.0.1:5000/actuator/health",
"|",
"grep 'UP'"
],
"Interval": 30000000000,
"Timeout": 3000000000,
"StartPeriod": 10000000000,
"Retries": 3
解决方案
CMD-SHELL
接受一个参数,字符串被传递给处理字符串解析的shell:
test: ["CMD-SHELL", "curl -s -X GET http://127.0.0.1:5000/actuator/health | grep 'UP'"]
推荐阅读
- reactjs - 如何从 withHandlers 调用另一个函数?
- angular - 如何在重新加载时在组件之间保留共享服务数据
- python - 在 Spyder 中运行 Vpython 时出错(NameError: name 'gsprint' is not defined)
- sql - Excel 公式到 SQL
- java - 构建 SNAPSHOT 时不会触发 Jenkins Multibranch 项目
- html - 通过链接文本抓取网页
- python-2.7 - 在通过 init 脚本启动的 python 脚本中,无法通过 os.system('scp (...)') 下载文件
- c# - 跟踪侦听器未生成日志文件
- c++ - 如何设置 vscode 错误列表以使用 nvcc 的输出
- python - Python:如何获取列表内字典内的 id 字段