赞
踩
在使用 Docker 时,docker inspect
命令是一个非常有用的工具,它能够返回容器或镜像的详细配置信息和状态。以下是对 docker inspect mysql
命令输出的字段的详细解释,这些信息可以帮助您更好地了解容器的内部工作机制。
Path
命令的参数。resolv.conf
文件的路径,用于DNS解析。hostname
文件的路径。hosts
文件的路径。下面是MySQL 容器的具体信息
[ { "Id": "c10bb6d74719b1c121f501f27ed1d5b6cf3f5a24a1a28b0ac53728e3ae5015aa", "Created": "2024-01-22T16:38:51.768765699Z", "Path": "docker-entrypoint.sh", "Args": [ "mysqld" ], "State": { "Status": "exited", "Running": false, "Paused": false, "Restarting": false, "OOMKilled": false, "Dead": false, "Pid": 0, "ExitCode": 0, "Error": "", "StartedAt": "2024-05-23T09:33:17.914478642Z", "FinishedAt": "2024-05-23T09:48:06.466321364Z" }, "Image": "sha256:a76e521c029290a5e42acd182b67a66b8bf1c42045e4a6977ee21e46a5fe6083", "ResolvConfPath": "/var/lib/docker/containers/c10bb6d74719b1c121f501f27ed1d5b6cf3f5a24a1a28b0ac53728e3ae5015aa/resolv.conf", "HostnamePath": "/var/lib/docker/containers/c10bb6d74719b1c121f501f27ed1d5b6cf3f5a24a1a28b0ac53728e3ae5015aa/hostname", "HostsPath": "/var/lib/docker/containers/c10bb6d74719b1c121f501f27ed1d5b6cf3f5a24a1a28b0ac53728e3ae5015aa/hosts", "LogPath": "/var/lib/docker/containers/c10bb6d74719b1c121f501f27ed1d5b6cf3f5a24a1a28b0ac53728e3ae5015aa/c10bb6d74719b1c121f501f27ed1d5b6cf3f5a24a1a28b0ac53728e3ae5015aa-json.log", "Name": "/mysql", "RestartCount": 0, "Driver": "overlay2", "Platform": "linux", "MountLabel": "", "ProcessLabel": "", "AppArmorProfile": "", "ExecIDs": null, "HostConfig": { "Binds": [ "/data/mysql/data:/var/lib/mysql", "/data/mysql/log:/var/log/mysql" ], "ContainerIDFile": "", "LogConfig": { "Type": "json-file", "Config": {} }, "NetworkMode": "default", "PortBindings": { "3306/tcp": [ { "HostIp": "", "HostPort": "3306" } ] }, "RestartPolicy": { "Name": "no", "MaximumRetryCount": 0 }, "AutoRemove": false, "VolumeDriver": "", "VolumesFrom": null, "ConsoleSize": [ 42, 244 ], "CapAdd": null, "CapDrop": null, "CgroupnsMode": "host", "Dns": [], "DnsOptions": [], "DnsSearch": [], "ExtraHosts": null, "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": [], "BlkioDeviceReadBps": [], "BlkioDeviceWriteBps": [], "BlkioDeviceReadIOps": [], "BlkioDeviceWriteIOps": [], "CpuPeriod": 0, "CpuQuota": 0, "CpuRealtimePeriod": 0, "CpuRealtimeRuntime": 0, "CpusetCpus": "", "CpusetMems": "", "Devices": [], "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" ], "ReadonlyPaths": [ "/proc/bus", "/proc/fs", "/proc/irq", "/proc/sys", "/proc/sysrq-trigger" ] }, "GraphDriver": { "Data": { "LowerDir": "/var/lib/docker/overlay2/01dedce078bd1c2af754487cee12c86cab6d987950101d380dfded0cbdaa12df-init/diff:/var/lib/docker/overlay2/319aac45583cc5f754f5deb1e73ec5276ebfe5f9665db0e397ac5b54c366869a/diff:/var/lib/docker/overlay2/4a6898e42bda63895dcdf49a5209a0d5e52af1faa7b2aba00a7773777f4c11e2/diff:/var/lib/docker/overlay2/8478b01f22db70f2eb5f24672de76e48e8cc31dc906ce1285382c5c015ec5181/diff:/var/lib/docker/overlay2/3c0e9db579de29a2c0019f34386195799cc76f65f85e2cca45cf9abb77c57bc1/diff:/var/lib/docker/overlay2/d6adf9ed222557d6da87f1b1174bc01694aabad814b1dfab6400d2ced00792c8/diff:/var/lib/docker/overlay2/de5f9a8002b2e064d9b07b0c5c83d0b5c3799e90ad48c5da13c17174e5a67864/diff:/var/lib/docker/overlay2/c4a0c15baa3c90adb6045d6073ab5dcc5af9b701109e9733132cf1cfec8e98af/diff:/var/lib/docker/overlay2/905e17d8eb5b1f3d7789cf06b4cfd679a751edd94b3ad81f8f7bc6f245b1d827/diff:/var/lib/docker/overlay2/e208f33a0338b61d869dfe8ad278d9660485838e45648f40c667e49136bc1e59/diff:/var/lib/docker/overlay2/a08238867e2ab34e2ec90e427210518ec5644784120d16ae366a3c4cce4fa2d8/diff", "MergedDir": "/var/lib/docker/overlay2/01dedce078bd1c2af754487cee12c86cab6d987950101d380dfded0cbdaa12df/merged", "UpperDir": "/var/lib/docker/overlay2/01dedce078bd1c2af754487cee12c86cab6d987950101d380dfded0cbdaa12df/diff", "WorkDir": "/var/lib/docker/overlay2/01dedce078bd1c2af754487cee12c86cab6d987950101d380dfded0cbdaa12df/work" }, "Name": "overlay2" }, "Mounts": [ { "Type": "bind", "Source": "/data/mysql/data", "Destination": "/var/lib/mysql", "Mode": "", "RW": true, "Propagation": "rprivate" }, { "Type": "bind", "Source": "/data/mysql/log", "Destination": "/var/log/mysql", "Mode": "", "RW": true, "Propagation": "rprivate" } ], "Config": { "Hostname": "c10bb6d74719", "Domainname": "", "User": "", "AttachStdin": false, "AttachStdout": false, "AttachStderr": false, "ExposedPorts": { "3306/tcp": {}, "33060/tcp": {} }, "Tty": false, "OpenStdin": false, "StdinOnce": false, "Env": [ "MYSQL_ROOT_PASSWORD=root", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "GOSU_VERSION=1.16", "MYSQL_MAJOR=innovation", "MYSQL_VERSION=8.2.0-1.el8", "MYSQL_SHELL_VERSION=8.2.1-1.el8" ], "Cmd": [ "mysqld" ], "Image": "mysql", "Volumes": { "/var/lib/mysql": {} }, "WorkingDir": "", "Entrypoint": [ "docker-entrypoint.sh" ], "OnBuild": null, "Labels": {} }, "NetworkSettings": { "Bridge": "", "SandboxID": "63732c0dc9176da4496fd6a75980f955a66ae8d5e7b99dcf3f6c48430de271bb", "HairpinMode": false, "LinkLocalIPv6Address": "", "LinkLocalIPv6PrefixLen": 0, "Ports": {}, "SandboxKey": "/var/run/docker/netns/63732c0dc917", "SecondaryIPAddresses": null, "SecondaryIPv6Addresses": null, "EndpointID": "", "Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "IPAddress": "", "IPPrefixLen": 0, "IPv6Gateway": "", "MacAddress": "", "Networks": { "bridge": { "IPAMConfig": null, "Links": null, "Aliases": null, "NetworkID": "f00da04ad0469c7c6d5e7d1a02bb92d429db67bffc642dd1af246ed2e73a293a", "EndpointID": "", "Gateway": "", "IPAddress": "", "IPPrefixLen": 0, "IPv6Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "MacAddress": "", "DriverOpts": null } } } } ]
c10bb6d74719b1c121f501f27ed1d5b6cf3f5a24a1a28b0ac53728e3ae5015aa
是容器的唯一标识符,用于识别具体的容器实例。2024-01-22T16:38:51.768765699Z
表示容器创建的时间。docker-entrypoint.sh
是容器启动时执行的脚本。["mysqld"]
是传递给 docker-entrypoint.sh
脚本的参数,用于启动 MySQL 服务。exited
表示容器已经退出。false
表示容器当前没有运行。false
表示容器没有被暂停。false
表示容器没有在尝试重启。false
表示容器没有被OOM(Out of Memory)机制杀掉。false
表示容器没有死亡。0
表示主进程的ID,通常在容器停止时为0。0
表示容器正常退出。2024-05-23T09:33:17.914478642Z
表示容器上次启动的时间。2024-05-23T09:48:06.466321364Z
表示容器上次停止的时间。sha256:a76e521c029290a5e42acd182b67a66b8bf1c42045e4a6977ee21e46a5fe6083
是容器使用的镜像的摘要信息。resolv.conf
的路径。hostname
和 hosts
文件的路径,用于配置容器的网络主机名。"/mysql"
是容器的名称。overlay2
是 Docker 用来存储镜像和容器数据的存储驱动。default
表示容器使用的是默认的网络模式。3306/tcp
映射到宿主机的 3306
端口。"/data/mysql/data:/var/lib/mysql"
和 "/data/mysql/log:/var/log/mysql"
分别表示宿主机上的 /data/mysql/data
和 /data/mysql/log
目录挂载到容器内的 /var/lib/mysql
和 /var/log/mysql
。host
表示容器使用宿主机的控制组命名空间。private
表示容器有私有的 IPC 命名空间。[42, 244]
表示容器的标准输入和输出的控制台大小。0
表示容器没有特定的 CPU 和内存资源限制。0
表示容器的OOM(Out of Memory)杀死分数调整,负值表示较低的杀死优先级。overlay2
。以上字段提供了容器的全面视图,包括它的配置、状态、资源限制、挂载卷、网络设置和环境变量。这些信息对于容器的调试、维护和管理至关重要。# 解读 MySQL 容器信息:docker inspect
输出详解
在 Docker 中,docker inspect
命令提供了一种方法来获取容器或镜像的详细底层信息。以下是针对您提供的 MySQL 容器信息的具体解释:
c10bb6d74719b1c121f501f27ed1d5b6cf3f5a24a1a28b0ac53728e3ae5015aa
是容器的唯一标识符,用于识别具体的容器实例。2024-01-22T16:38:51.768765699Z
表示容器创建的时间。docker-entrypoint.sh
是容器启动时执行的脚本。["mysqld"]
是传递给 docker-entrypoint.sh
脚本的参数,用于启动 MySQL 服务。exited
表示容器已经退出。false
表示容器当前没有运行。false
表示容器没有被暂停。false
表示容器没有在尝试重启。false
表示容器没有被OOM(Out of Memory)机制杀掉。false
表示容器没有死亡。0
表示主进程的ID,通常在容器停止时为0。0
表示容器正常退出。2024-05-23T09:33:17.914478642Z
表示容器上次启动的时间。2024-05-23T09:48:06.466321364Z
表示容器上次停止的时间。sha256:a76e521c029290a5e42acd182b67a66b8bf1c42045e4a6977ee21e46a5fe6083
是容器使用的镜像的摘要信息。resolv.conf
的路径。hostname
和 hosts
文件的路径,用于配置容器的网络主机名。"/mysql"
是容器的名称。overlay2
是 Docker 用来存储镜像和容器数据的存储驱动。default
表示容器使用的是默认的网络模式。3306/tcp
映射到宿主机的 3306
端口。"/data/mysql/data:/var/lib/mysql"
和 "/data/mysql/log:/var/log/mysql"
分别表示宿主机上的 /data/mysql/data
和 /data/mysql/log
目录挂载到容器内的 /var/lib/mysql
和 /var/log/mysql
。host
表示容器使用宿主机的控制组命名空间。private
表示容器有私有的 IPC 命名空间。[42, 244]
表示容器的标准输入和输出的控制台大小。0
表示容器没有特定的 CPU 和内存资源限制。0
表示容器的OOM(Out of Memory)杀死分数调整,负值表示较低的杀死优先级。overlay2
。以上字段提供了容器的全面视图,包括它的配置、状态、资源限制、挂载卷、网络设置和环境变量。这些信息对于容器的调试、维护和管理至关重要。
理解 docker inspect
命令的输出可以帮助您更好地管理和调试 Docker 容器。通过这些详细的信息,您可以获得容器的配置、状态、资源使用情况等关键数据,这对于维护和优化容器化应用至关重要。
分享一个有趣的 学习链接
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。