对docker api使用/ container / id / top命令

时间:2014-07-23 23:58:13

标签: api docker

我对docker很陌生,但对它的功能印象深刻!

我遇到的一个问题是,当我运行/ container / id / top api时,我得到了一些属性值,但不是我在文档中看到的那些。

docker remote API documents,我看到: 列出在容器内运行的进程 GET / containers /(id)/ top

列出在容器ID

中运行的进程

示例请求

GET /containers/4fa6e0f0c678/top HTTP/1.1

示例回复

HTTP/1.1 200 OK
Content-Type: application/json

{
     "Titles":[
             "USER",
             "PID",
             "%CPU",
             "%MEM",
             "VSZ",
             "RSS",
             "TTY",
             "STAT",
             "START",
             "TIME",
             "COMMAND"
             ],
     "Processes":[
             ["root","20147","0.0","0.1","18060","1864","pts/4","S","10:06","0:00","bash"],
             ["root","20271","0.0","0.0","4312","352","pts/4","S+","10:07","0:00","sleep","10"]
     ]
}

但是当我在启用了Dock的VM上运行相同的api时,我得到了

"Processes": [
    [
        "root",
        "27467",
        "1449",
        "0",
        "19:39",
        "pts/3",
        "00:00:00",
        "/bin/bash"
    ],
    [
        "root",
        "28010",
        "27467",
        "0",
        "19:46",
        "pts/3",
        "00:11:03",
        "/bin/bash"
    ]
],
"Titles": [
    "UID",
    "PID",
    "PPID",
    "C",
    "STIME",
    "TTY",
    "TIME",
    "CMD"
]

不包含cpu和mem%。我需要启用什么吗?

我的泊坞版是 suse64:〜#docker version 客户端版本:1.1.1 客户端API版本:1.13 Go版本(客户端):go1.3 Git commit(client):dc62f3c 服务器版本:1.1.1 服务器API版本:1.13 转到版本(服务器):go1.3 Git commit(server):dc62f3c

提前多多感谢。 恩林

1 个答案:

答案 0 :(得分:1)

您似乎需要查询?ps_args=-aux参数。例如:

http://127.0.0.1:2375/v1.10/containers/<contained_id>/top?ps_args=-aux

这应该返回json对象中所有进程的cpu和内存统计信息。

来源:Similar issues on github