所有Docker容器状态? [英] All Docker container statuses?

查看:623
本文介绍了所有Docker容器状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Docker状态列表为此处。但是,当我使用API​​列出Docker容器时,状态以自然语句显示;例如:

The list of Docker statuses is here. However, when I list docker containers using the API, the statuses are shown in 'natural' sentences; e.g.:


  • 已退出(0)NN秒前

  • 最多NN天

  • 依此类推...

我找不到所有状态的所有字符串输出的确定列表。换句话说,我想解析Docker API状态字符串。

I couldn't find the definitive list of all string outputs for all the statuses. In other words, I want to parse docker API status strings.

Docker API对于容器状态的所有可能输出是什么?

What are all the possible outputs of the Docker API for container statuses?

这是 api 我在谈论。

推荐答案

生成状态摘要的逻辑可以在 Docker源代码,位于文件 container / states.go c $ c>,湖41ff。。基本上,您将获得以下之一:

The logic by which the status summary is generated can be found in the Docker source code, in the file container/states.go, l. 41ff.. Basically, you'll get one of the following:


  • 最多1天(已暂停)

  • 重新启动(123)1天前

  • 最多1天

  • 移除中

  • 已死

  • 已创建

  • 1天前退出(123)

  • (空字符串)

  • Up 1 day (paused)
  • Restarting (123) 1 day ago
  • Up 1 day
  • Removal in Progress
  • Dead
  • Created
  • Exited (123) 1 day ago
  • (empty string)

为了获得机器可读的输出,我建议使用 / containers /:id / json 端点,它将返回数据结构如下:

In order to get a machine-readable output, I'd suggest using the /containers/:id/json endpoint, which will return a data structure like the following:

"State": {
    "Dead": false, 
    "Error": "", 
    "ExitCode": 0, 
    "FinishedAt": "0001-01-01T00:00:00Z", 
    "OOMKilled": false, 
    "Paused": false, 
    "Pid": 2593, 
    "Restarting": false, 
    "Running": true, 
    "StartedAt": "2015-12-26T19:22:38.616937722Z", 
    "Status": "running"
}

这篇关于所有Docker容器状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆