Docker容器卡在(health: starting)状态

7

我像这样给我的容器添加了一个新的健康检查:

 app:
      ...
       labels:
          - autoheal=true 
       healthcheck:
          test: ["CMD", 'curl -o /dev/null -s -w "%{http_code}\n" http://localhost:3000/health --connect-timeout 30 --max-time 30 | grep 200']
          interval: 30s
          timeout: 60s
          retries: 3
       logging:
          driver: "syslog"
          options:
              syslog-address: "tcp://127.0.0.1:601"
       depends_on:
          - scalyr 

我输入"docker container ls"时,健康检查仍在启动中:

"sh run-node" 11分钟前 上线5分钟 (健康状态:启动中)

2个回答

5

我也遇到了同样的问题,我的情况是我使用的是curl,但在Alpine镜像中,默认情况下未安装

以下是等效的HEALTHCHECK代码,使用wget(Alpine中可用):

HEALTHCHECK --interval=30s --timeout=60s --retries=3 \
  CMD wget --no-verbose --tries=1 --spider http://localhost:3000/health || exit 1

0

我曾经遇到过类似的问题,我将内存分配从默认的2.00GB增加到了4.00GB。只需进入首选项>资源>高级,然后更改内存量并应用并重启即可。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接