通过任务json的容器健康状况检查状态

我正在尝试使用docker远程API获取容器状态。 v1.26

我正在调用/任务api来获取节点的任务列表。 有没有办法从GET /任务JSON映射到“健康”的容器状态:{“状态”:“健康”返回时制作/容器/ JSON?

我基本上正在寻找一个相当于/任务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例子,我看到2个不同的情况:

状态:正在运行

 "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",