Docker:使用 Healthchecks.io 的 Healthcheck-cmd 导致容器在创建后立即失败

问题描述 投票:0回答:1

我正在尝试使用 Healthchecks.io 作为监视器创建一个容器。当容器成功创建并保持运行时,健康检查永远不会完成。它从不 ping healthchecks.io 以获取任何更新。在 60 秒后检查“docker container list --all”时,healthcheck 不断显示“health: starting”并且从不改变。 healthchecks.io 网站永远不会更新。我确认图像确实安装了 curl。这不是由 YAML 组成,而是内联“docker run”

我做错了什么或我做错了什么?

容器为:binhex/arch-delugevpn。我确认容器中也存在卷曲。

     --health-cmd="/bin/curl -Ss --fail https://hc-ping.com/UUID || exit 1" \
     --health-interval=1h \
     --health-retries=5 \
     --health-timeout=5s \
     --health-start-period=60s \

这是“docker inspect”创建后的输出。

"Healthcheck": {
                "Test": [
                    "CMD-SHELL",
                    "/bin/curl -Ss --fail https://hc-ping.com/UUID || exit 1"
                ],
                "Interval": 3600000000000,
                "Timeout": 5000000000,
                "StartPeriod": 60000000000,
                "Retries": 12

我已经尝试在 healthchecks.io 站点末尾操纵引号和引号类型(无、双引号和单引号)的位置,在没有和没有“ > /dev/null 2>&1” 的情况下可能会防止出现问题。 wget 不随容器一起提供。如果我只是在字符串中放置“curl”而不是“/bin/curl”,容器会创建但会退出。

docker integration
1个回答
0
投票

我做了以下实验——创建了一个包含以下内容的 Dockerfile:

FROM binhex/arch-delugevpn
HEALTHCHECK --interval=20s --timeout=10s CMD curl https://hc-ping.com/my-uuid-here || exit 1

建成:

docker build -t my-experiment .

然后运行它:

docker run -it --rm my-experiment bash

我现在在 Healthchecks.io 上每 20 秒看到一次 ping,报告的 curl 版本是

curl/7.88.1-DEV
.

你能让这个例子起作用吗?

然后我通过使用命令行参数覆盖 healthcheck 命令来测试它:

docker run -it --rm \
    --health-cmd="curl https://hc-ping.com/my-uuid-here || exit 1" \
    --health-interval=20s \
    --health-timeout=10s \
    binhex/arch-delugevpn bash

这也有效,我每 20 秒就会看到传入的 ping。

© www.soinside.com 2019 - 2024. All rights reserved.