docker inspect c5b

容器c5b信息输出到屏幕;

docker inspect c5b >> docker-inspect.log

容器c5b信息输出到docker-inspect.log文件

docker-inspect.log内容如下:

[
    {
        "Id": "c5bd6a8d8d001643f9832a798f515ff2cfaa2fbbba21f442eea333cd5280ed02",
        "Created": "2019-03-04T07:28:47.806023756Z",
        "Path": "docker-entrypoint.sh",
        "Args": [
            "mongod"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 81432,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2019-03-04T07:28:52.650867581Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:fb885d89ea5c35ac02acf79a398b793555cbb3216900f03f4b5f7dc31e595e31",
        "ResolvConfPath": "/home/docker/root/containers/c5bd6a8d8d001643f9832a798f515ff2cfaa2fbbba21f442eea333cd5280ed02/resolv.conf",
        "HostnamePath": "/home/docker/root/containers/c5bd6a8d8d001643f9832a798f515ff2cfaa2fbbba21f442eea333cd5280ed02/hostname",
        "HostsPath": "/home/docker/root/containers/c5bd6a8d8d001643f9832a798f515ff2cfaa2fbbba21f442eea333cd5280ed02/hosts",
        "LogPath": "/home/docker/root/containers/c5bd6a8d8d001643f9832a798f515ff2cfaa2fbbba21f442eea333cd5280ed02/c5bd6a8d8d001643f9832a798f515ff2cfaa2fbbba21f442eea333cd5280ed02-json.log",
        "Name": "/mongodb-bzy",
        "RestartCount": 0,
        "Driver": "devicemapper",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [
                "/data/mongodb0:/data/db"
            ],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "default",
            "PortBindings": {
                "27017/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "37017"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "no",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "CapAdd": null,
            "CapDrop": null,
            "Dns": [],
            "DnsOptions": [],
            "DnsSearch": [],
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "shareable",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": [],
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": [],
            "DeviceCgroupRules": null,
            "DiskQuota": 0,
            "KernelMemory": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": false,
            "PidsLimit": 0,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0
        },
        "GraphDriver": {
            "Data": {
                "DeviceId": "260",
                "DeviceName": "docker-253:3-184627201-2b8b068ee1086307ff7506f285759799ff0b676199dea94c441c2897a93521f6",
                "DeviceSize": "10737418240"
            },
            "Name": "devicemapper"
        },
        "Mounts": [
            {
                "Type": "bind",
                "Source": "/data/mongodb0",
                "Destination": "/data/db",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Type": "volume",
                "Name": "712668e0ca662961c1f228d498f41e50c8f979fde9f97900cd34cf6b766ec897",
                "Source": "/home/docker/root/volumes/712668e0ca662961c1f228d498f41e50c8f979fde9f97900cd34cf6b766ec897/_data",
                "Destination": "/data/configdb",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            }
        ],
        "Config": {
            "Hostname": "c5bd6a8d8d00",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "27017/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "GOSU_VERSION=1.10",
                "JSYAML_VERSION=3.10.0",
                "GPG_KEYS=DFFA3DCF326E302C4787673A01C4E7FAAAB2461C \t42F3E95A2C4F08279C4960ADD68FA50FEA312927",
                "MONGO_PACKAGE=mongodb-org",
                "MONGO_REPO=repo.mongodb.org",
                "MONGO_MAJOR=3.2",
                "MONGO_VERSION=3.2.21"
            ],
            "Cmd": [
                "mongod"
            ],
            "ArgsEscaped": true,
            "Image": "mongo:3.2",
            "Volumes": {
                "/data/configdb": {},
                "/data/db": {}
            },
            "WorkingDir": "",
            "Entrypoint": [
                "docker-entrypoint.sh"
            ],
            "OnBuild": null,
            "Labels": {}
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "896a3cf44774f84ff8b9ff1efe21f65c04d94a3deb6c56d9ff70a8baf7c56d25",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "27017/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "37017"
                    }
                ]
            },
            "SandboxKey": "/var/run/docker/netns/896a3cf44774",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "0a6ac310c390c5c932e0182fb9343eca05090e2f8d8c2ad842079826d96e5517",
            "Gateway": "172.17.0.1",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "172.17.0.6",
            "IPPrefixLen": 16,
            "IPv6Gateway": "",
            "MacAddress": "02:42:ac:11:00:06",
            "Networks": {
                "bridge": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "c3fcf533e8ea32409f50c3ca2996605e1db1982b4137c15647923363596c3412",
                    "EndpointID": "0a6ac310c390c5c932e0182fb9343eca05090e2f8d8c2ad842079826d96e5517",
                    "Gateway": "172.17.0.1",
                    "IPAddress": "172.17.0.6",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:11:00:06",
                    "DriverOpts": null
                }
            }
        }
    }
]

查看容器备注名字:

docker inspect -f {{.Name}} c5b

输出:

查看容器端口映射:

docker inspect -f {{.NetworkSettings.Ports}} c5b

输出:

查看docker inspect 用法:

docker inspect --help

 

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐