用于docker检查的curl命令

时间:2015-06-24 11:19:40

标签: docker boot2docker dockerhub

我已经看到了一些curl命令来搜索,从docker中提取图像等。提供了一些示例here

sudo docker inspect nginx的等价代码是什么?

在终端中,其输出如下。

[
{
    "Id": "319d2015d149943ff4d2a20ddea7d7e5ce06a64bbab1792334c0d3273bbbff1e",
    "Parent": "107c338c1d31577c86670a0aa070ed903c9e00802838f9ffb8420a6acfb3dbaf",
    "Comment": "",
    "Created": "2015-06-16T21:50:45.835843344Z",
    "Container": "e9b1150a37d45ba2335ee36436e7d435c1ce1d2960720cd1d06c194c2db13d8f",
    "ContainerConfig": {
        "Hostname": "6c732c6044b7",
        "Domainname": "",
        "User": "",
        "AttachStdin": false,
        "AttachStdout": false,
        "AttachStderr": false,
        "PortSpecs": null,
        "ExposedPorts": {
            "443/tcp": {},
            "80/tcp": {}
        },
        "Tty": false,
        "OpenStdin": false,
        "StdinOnce": false,
        "Env": [
            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
            "NGINX_VERSION=1.9.2-1~jessie"
        ],
        "Cmd": [
            "/bin/sh",
            "-c",
            "#(nop) CMD [\"nginx\" \"-g\" \"daemon off;\"]"
        ],
        "Image": "107c338c1d31577c86670a0aa070ed903c9e00802838f9ffb8420a6acfb3dbaf",
        "Volumes": {
            "/var/cache/nginx": {}
        },
        "VolumeDriver": "",
        "WorkingDir": "",
        "Entrypoint": null,
        "NetworkDisabled": false,
        "MacAddress": "",
        "OnBuild": [],
        "Labels": {}
    },
    "DockerVersion": "1.6.0",
    "Author": "NGINX Docker Maintainers \"docker-maint@nginx.com\"",
    "Config": {
        "Hostname": "6c732c6044b7",
        "Domainname": "",
        "User": "",
        "AttachStdin": false,
        "AttachStdout": false,
        "AttachStderr": false,
        "PortSpecs": null,
        "ExposedPorts": {
            "443/tcp": {},
            "80/tcp": {}
        },
        "Tty": false,
        "OpenStdin": false,
        "StdinOnce": false,
        "Env": [
            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
            "NGINX_VERSION=1.9.2-1~jessie"
        ],
        "Cmd": [
            "nginx",
            "-g",
            "daemon off;"
        ],
        "Image": "107c338c1d31577c86670a0aa070ed903c9e00802838f9ffb8420a6acfb3dbaf",
        "Volumes": {
            "/var/cache/nginx": {}
        },
        "VolumeDriver": "",
        "WorkingDir": "",
        "Entrypoint": null,
        "NetworkDisabled": false,
        "MacAddress": "",
        "OnBuild": [],
        "Labels": {}
    },
    "Architecture": "amd64",
    "Os": "linux",
    "Size": 0,
    "VirtualSize": 132841390
}
]

1 个答案:

答案 0 :(得分:3)

任何泊坞窗命令(docker psdocker stats ...)都是对API的调用。从最新的1.7 doc https://docs.docker.com/reference/api/docker_remote_api_v1.17/我看到

检查容器

GET /containers/(id)/json

返回有关容器ID的低级信息

示例请求:

GET /containers/4fa6e0f0c678/json HTTP/1.1