我正在尝试使用 docker 远程 API 获取容器状态。v1.26
我正在调用 /tasks api 来获取节点的任务列表。有没有办法从 GET /tasks json 获取容器状态,它映射到制作 /containers/json 时返回的 "Health":{"Status":"healthy" ?
我基本上是在寻找 /container 在 /tasks api 中提供的健康检查等价物
我正在尝试使用 docker 远程 API 获取容器状态。v1.26
我正在调用 /tasks api 来获取节点的任务列表。有没有办法从 GET /tasks json 获取容器状态,它映射到制作 /containers/json 时返回的 "Health":{"Status":"healthy" ?
我基本上是在寻找 /container 在 /tasks api 中提供的健康检查等价物
从这个来源:https ://docs.docker.com/engine/api/v1.26/#operation/ContainerInspect
我认为您可以通过以下方式获得所需的信息:
GET /containers/{id}/json
在返回的 json 中有很多东西,也许您正在寻找以下内容:
"State":
{
"Error": "",
"ExitCode": 9,
"FinishedAt": "2015-01-06T15:47:32.080254511Z",
"OOMKilled": false,
"Dead": false,
"Paused": false,
"Pid": 0,
"Restarting": false,
"Running": true,
"StartedAt": "2015-01-06T15:47:32.072697474Z",
"Status": "running"
},
编辑:
从GET /tasks
示例中,我看到了两种不同的情况:
"ID": "0kzzo1i0y4jz6027t0k7aezc7",
"Status":
{
"Timestamp": "2016-06-07T21:07:31.290032978Z",
"State": "running",
"Message": "started",
"ContainerStatus":
{
"ContainerID": "e5d62702a1b48d01c3e02ca1e0212a250801fa8d67caca0b6f35919ebc12f035",
"PID": 677
}
},
"DesiredState": "running",
"ID": "1yljwbmlr8er2waf8orvqpwms",
"Status":
{
"Timestamp": "2016-06-07T21:07:30.202183143Z",
"State": "shutdown",
"Message": "shutdown",
"ContainerStatus":
{
"ContainerID": "1cf8d63d18e79668b0004a4be4c6ee58cddfad2dae29506d8781581d0688a213"
}
},
"DesiredState": "shutdown",