docker之旅 9.查看容器详情 inspect
1.查看同级信息,包括cpu,内存,存储,网络等
docker container stats b8f3107e7f5c
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS b8f3107e7f5c dockerpath-mysql-1 0.78% 395.2MiB / 7.624GiB 5.06% 2.6kB / 0B 122MB / 15.5MB 38
2.查看 b8f3107e7f5c 容器的详情
docker container inspect b8f3107e7f5c
可以看到容器的配置信息,包括端口,网络等等。是非常有用的一个命令。
[henry@192 workspace]$ docker container inspect b8f3107e7f5c [ { "Id": "b8f3107e7f5c51589485d4620e33203cb55b184f888ff8680b3d396725608179", "Created": "2024-04-27T00:13:15.271465248Z", "Path": "docker-entrypoint.sh", "Args": [ "mysqld" ], "State": { "Status": "running", "Running": true, "Paused": false, "Restarting": false, "OOMKilled": false, "Dead": false, "Pid": 3099, "ExitCode": 0, "Error": "", "StartedAt": "2024-04-28T21:21:32.720828697Z", "FinishedAt": "2024-04-28T21:21:29.014949648Z" }, "Image": "sha256:6f343283ab56d883ec8ea17641b5d61d0252cc6c97dad3849cf3681dd1e2f37d", "ResolvConfPath": "/var/lib/docker/containers/b8f3107e7f5c51589485d4620e33203cb55b184f888ff8680b3d396725608179/resolv.conf", "HostnamePath": "/var/lib/docker/containers/b8f3107e7f5c51589485d4620e33203cb55b184f888ff8680b3d396725608179/hostname", "HostsPath": "/var/lib/docker/containers/b8f3107e7f5c51589485d4620e33203cb55b184f888ff8680b3d396725608179/hosts", "LogPath": "/var/lib/docker/containers/b8f3107e7f5c51589485d4620e33203cb55b184f888ff8680b3d396725608179/b8f3107e7f5c51589485d4620e33203cb55b184f888ff8680b3d396725608179-json.log", "Name": "/dockerpath-mysql-1", "RestartCount": 0, "Driver": "overlay2", "Platform": "linux", "MountLabel": "", "ProcessLabel": "", "AppArmorProfile": "", "ExecIDs": [ "6c990559a890938efa27e01a79cd2476874dd3d91d02273059dc66a1a48b5497" ], "HostConfig": { "Binds": [ "/home/henry/mysqlFilePath:/var/lib/mysql:rw" ], "ContainerIDFile": "", "LogConfig": { "Type": "json-file", "Config": {} }, "NetworkMode": "dockerpath_default", "PortBindings": { "3306/tcp": [ { "HostIp": "", "HostPort": "3307" } ] }, "RestartPolicy": { "Name": "always", "MaximumRetryCount": 0 }, "AutoRemove": false, "VolumeDriver": "", "VolumesFrom": null, "ConsoleSize": [ 0, 0 ], "CapAdd": null, "CapDrop": null, "CgroupnsMode": "host", "Dns": [], "DnsOptions": [], "DnsSearch": [], "ExtraHosts": [], "GroupAdd": null, "IpcMode": "private", "Cgroup": "", "Links": null, "OomScoreAdj": 0, "PidMode": "", "Privileged": false, "PublishAllPorts": false, "ReadonlyRootfs": false, "SecurityOpt": null, "UTSMode": "", "UsernsMode": "", "ShmSize": 67108864, "Runtime": "runc", "Isolation": "", "CpuShares": 0, "Memory": 0, "NanoCpus": 0, "CgroupParent": "", "BlkioWeight": 0, "BlkioWeightDevice": null, "BlkioDeviceReadBps": null, "BlkioDeviceWriteBps": null, "BlkioDeviceReadIOps": null, "BlkioDeviceWriteIOps": null, "CpuPeriod": 0, "CpuQuota": 0, "CpuRealtimePeriod": 0, "CpuRealtimeRuntime": 0, "CpusetCpus": "", "CpusetMems": "", "Devices": null, "DeviceCgroupRules": null, "DeviceRequests": null, "MemoryReservation": 0, "MemorySwap": 0, "MemorySwappiness": null, "OomKillDisable": false, "PidsLimit": null, "Ulimits": null, "CpuCount": 0, "CpuPercent": 0, "IOMaximumIOps": 0, "IOMaximumBandwidth": 0, "MaskedPaths": [ "/proc/asound", "/proc/acpi", "/proc/kcore", "/proc/keys", "/proc/latency_stats", "/proc/timer_list", "/proc/timer_stats", "/proc/sched_debug", "/proc/scsi", "/sys/firmware", "/sys/devices/virtual/powercap" ], "ReadonlyPaths": [ "/proc/bus", "/proc/fs", "/proc/irq", "/proc/sys", "/proc/sysrq-trigger" ] }, "GraphDriver": { "Data": { "LowerDir": "/var/lib/docker/overlay2/b86507d4d5e1567209827ed14c6f63da09cc14cedb4fd96c5d40958f8f1e57f2-init/diff:/var/lib/docker/overlay2/de1ce0cb987f3a8da4831eed2a8c8dca32bd27d212fe890d18d00f7ef4a52c64/diff:/var/lib/docker/overlay2/97647b9d4cc2e6aeb39f48361d118954a01c032e9a301201e9eaa77aa052b104/diff:/var/lib/docker/overlay2/c0bfdfbabbb61982082f2dcbeb8b7f1237237339b2bb6e0dccb19bfa6ee376c5/diff:/var/lib/docker/overlay2/b5363b3dbdbfa3479d739f610da97f9e4498badb3a42a5b57c67f5fb79d76616/diff:/var/lib/docker/overlay2/0c9ebf67112990ff19b4091be506a2d58ad64005339de9af89b871478a348414/diff:/var/lib/docker/overlay2/b30014efb75afc40b18f2a85bad303f2529487f3713a1ee5695a9065eeea9457/diff:/var/lib/docker/overlay2/cb140d235a030b4a7084db00b99967dc9438ae41a84bfa47c3c357844880c6cd/diff:/var/lib/docker/overlay2/620d422070581abc736253925f02c88f17e56494f38ae93fa447508c1515a570/diff:/var/lib/docker/overlay2/26fdaf632066471db85ccc85a79e83396209b1c0cd5236d4020107fe7093ff67/diff:/var/lib/docker/overlay2/76c70ed7d90e0c6705ee4fc5d5d6a5d4cfaf9d9be56c7c7d4ff22a33b47f9f1d/diff", "MergedDir": "/var/lib/docker/overlay2/b86507d4d5e1567209827ed14c6f63da09cc14cedb4fd96c5d40958f8f1e57f2/merged", "UpperDir": "/var/lib/docker/overlay2/b86507d4d5e1567209827ed14c6f63da09cc14cedb4fd96c5d40958f8f1e57f2/diff", "WorkDir": "/var/lib/docker/overlay2/b86507d4d5e1567209827ed14c6f63da09cc14cedb4fd96c5d40958f8f1e57f2/work" }, "Name": "overlay2" }, "Mounts": [ { "Type": "bind", "Source": "/home/henry/mysqlFilePath", "Destination": "/var/lib/mysql", "Mode": "rw", "RW": true, "Propagation": "rprivate" } ], "Config": { "Hostname": "b8f3107e7f5c", "Domainname": "", "User": "", "AttachStdin": false, "AttachStdout": true, "AttachStderr": true, "ExposedPorts": { "3306/tcp": {}, "33060/tcp": {} }, "Tty": false, "OpenStdin": false, "StdinOnce": false, "Env": [ "MYSQL_USER=henry", "MYSQL_PASSWORD=henry6764", "MYSQL_ROOT_PASSWORD=henry6764", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "GOSU_VERSION=1.17", "MYSQL_MAJOR=innovation", "MYSQL_VERSION=8.3.0-1.el8", "MYSQL_SHELL_VERSION=8.3.0-1.el8" ], "Cmd": [ "mysqld" ], "Image": "mysql", "Volumes": { "/var/lib/mysql": {} }, "WorkingDir": "", "Entrypoint": [ "docker-entrypoint.sh" ], "OnBuild": null, "Labels": { "com.docker.compose.config-hash": "4c230feea3beaf7c83df9b2217a5af486bbb1fa161b219fd8f2039dc0ac05e25", "com.docker.compose.container-number": "1", "com.docker.compose.depends_on": "", "com.docker.compose.image": "sha256:6f343283ab56d883ec8ea17641b5d61d0252cc6c97dad3849cf3681dd1e2f37d", "com.docker.compose.oneoff": "False", "com.docker.compose.project": "dockerpath", "com.docker.compose.project.config_files": "/home/henry/dockerPath/docker-compose.yml", "com.docker.compose.project.working_dir": "/home/henry/dockerPath", "com.docker.compose.replace": "875278c0fe2a8a40d287c2d9ea4cd6b151b9642bd3f3b2a401f9b51e9d09d3a2", "com.docker.compose.service": "mysql", "com.docker.compose.version": "2.27.0" } }, "NetworkSettings": { "Bridge": "", "SandboxID": "2d61145d0d87e2f2cca2ea05cc7fb0c0435da4fc44d74fa67720d18981af1023", "SandboxKey": "/var/run/docker/netns/2d61145d0d87", "Ports": { "3306/tcp": [ { "HostIp": "0.0.0.0", "HostPort": "3307" }, { "HostIp": "::", "HostPort": "3307" } ], "33060/tcp": null }, "HairpinMode": false, "LinkLocalIPv6Address": "", "LinkLocalIPv6PrefixLen": 0, "SecondaryIPAddresses": null, "SecondaryIPv6Addresses": null, "EndpointID": "", "Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "IPAddress": "", "IPPrefixLen": 0, "IPv6Gateway": "", "MacAddress": "", "Networks": { "dockerpath_default": { "IPAMConfig": null, "Links": null, "Aliases": [ "dockerpath-mysql-1", "mysql" ], "MacAddress": "02:42:ac:12:00:04", "NetworkID": "f55b5b736cf97e89a9749495e910f44731e0b0593d75867556eae21826d92f6c", "EndpointID": "b7cf8cf8a6747a3645a3b2fa71069b54f56d6d35d0bcac6b8e2dc272f1b63289", "Gateway": "172.18.0.1", "IPAddress": "172.18.0.4", "IPPrefixLen": 16, "IPv6Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "DriverOpts": null, "DNSNames": [ "dockerpath-mysql-1", "mysql", "b8f3107e7f5c" ] } } } } ]