Consul healthcheck 运行后状态为“Dead”的 Docker 容器

2024-02-16

我正在使用领事的健康检查功能,并且我不断收到这些“死”容器:

CONTAINER ID  IMAGE                   COMMAND              CREATED         STATUS              PORTS                                                                                                                                                                    NAMES
20fd397ba638  progrium/consul:latest  "\"/bin/bash -c 'cur 15 minutes ago  Dead

什么是“死”容器?停止的容器什么时候会变成“死亡”?

作为记录,我运行 progrium/consul + gliderlabs/registrator images + SERVICE_XXXX_CHECK 环境变量来进行运行状况检查。它运行一个运行状况检查脚本,每 X 秒运行一个图像,类似于docker run --rm my/img healthcheck.sh

我对“死亡”的含义以及如何防止它发生感兴趣。另一个奇怪的事情是我的死容器没有名字。

这是集装箱检查的一些信息:

  "State": {
        "Dead": true,
        "Error": "",
        "ExitCode": 1,
        "FinishedAt": "2015-05-30T19:00:01.814291614Z",
        "OOMKilled": false,
        "Paused": false,
        "Pid": 0,
        "Restarting": false,
        "Running": false,
        "StartedAt": "2015-05-30T18:59:51.739464262Z"
    },

奇怪的是,偶尔会有一个容器死掉并且没有被移除。

谢谢

编辑: 查看日志,我发现是什么导致容器停止失败:

  Handler for DELETE /containers/{name:.*} returned error: Cannot destroy container 003876e41429013e46187ebcf6acce1486bc5011435c610bd163b159ba550fbc: 
Driver aufs failed to remove root filesystem 003876e41429013e46187ebcf6acce1486bc5011435c610bd163b159ba550fbc: 
rename /var/lib/docker/aufs/diff/003876e41429013e46187ebcf6acce1486bc5011435c610bd163b159ba550fbc 
/var/lib/docker/aufs/ diff/003876e41429013e46187ebcf6acce1486bc5011435c610bd163b159ba550fbc-removing: 
device or resource busy

为什么会出现这种情况?

编辑2: 发现了这个:https://github.com/docker/docker/issues/9665 https://github.com/docker/docker/issues/9665


2016 年 3 月更新:问题 9665 https://github.com/docker/docker/issues/9665刚刚被关闭PR 21107 https://github.com/docker/docker/pull/21107(可能适用于 docker 1.11)
这应该有助于避免“驱动程序 aufs 无法删除根文件系统”、“设备或资源繁忙”问题。


原始答案 2015 年 5 月

死亡是一个,如果容器状态 https://github.com/docker/docker/blob/19790c46dc7fbd489bbd4ccd6f138663312e7579/api/types/types.go#L188,这是通过测试Container.Start() https://github.com/docker/docker/blob/00b8d37084934c5389afe3fd5558c7694cde0593/daemon/container.go#L230-L232

if container.removalInProgress || container.Dead {
        return fmt.Errorf("Container is marked for removal and cannot be started.")
}

It is 停止失败时设置 Dead https://github.com/docker/docker/blob/f3e56420a311378de030f7e3240fbdf6295c0b7e/daemon/delete.go#L86-L91,以防止该容器重新启动。

在可能的失败原因中,see container.Kill() https://github.com/docker/docker/blob/00b8d37084934c5389afe3fd5558c7694cde0593/daemon/container.go#L433-L450.
它的意思是kill -15 and kill -9都失败了。

// 1. Send a SIGTERM
if err := container.killPossiblyDeadProcess(15); err != nil {
    logrus.Infof("Failed to send SIGTERM to the process, force killing")
    if err := container.killPossiblyDeadProcess(9); err != nil {

正如OP提到的,这通常意味着繁忙的设备或资源,阻止进程被终止。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Consul healthcheck 运行后状态为“Dead”的 Docker 容器 的相关文章

随机推荐