为了确保容器的健康检查,我需要对多个URLS执行测试调用。
curl -f http://example.com和curl -f http://example2.com
是否有可能对码头工人的健康检查执行多次卷曲呼叫?
发布于 2021-09-01 21:51:00
可以将脚本设置为healthcheck命令,该命令包含执行健康检查的更复杂的逻辑。这样,您就可以通过curl执行多个请求,并且只有在所有请求都成功的情况下,脚本才会返回。
# example dockerfile
COPY files/healthcheck.sh /healthcheck.sh
RUN chmod +x /healthcheck.sh
HEALTHCHECK --interval=60s --timeout=10s --start-period=10s \
CMD /healthcheck.sh发布于 2021-07-25 17:31:48
虽然我不能测试,但我认为您可以使用以下方法
HEALTHCHECK CMD (curl --fail http://example.com && curl --fail http://example2.com) || exit 1如果希望首先手动检查此命令(没有退出部分),则可以通过以下方式检查最后一个错误代码
echo $? -> in linux和
echo %errorlevel% -> in windowshttps://stackoverflow.com/questions/68520574
复制相似问题