一、获取正在运行的容器ID
[root@izuf60j0xye9c3vxjqujjiz local]# docker ps
二、复制容器ID并查询
[root@izuf60j0xye9c3vxjqujjiz local]# docker inspect 3e27d4875c06
[
{
"Id": "3e27d4875c06f26562caf9d26d01c24d0a6fae6c5710bc23e429825844fc5f3a",
"Created": "2019-04-21T04:13:06.774375263Z",
"Path": "docker-entrypoint.sh",
"Args": [
"redis-server"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 14646,
"ExitCode": 0,
"Error": "",
"StartedAt": "2019-04-21T04:13:06.983559768Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:a55fbf438dfd878424c402e365ef3d80c634f07d0f5832193880ee1b95626e4e",
"ResolvConfPath": "/var/lib/docker/containers/3e27d4875c06f26562caf9d26d01c24d0a6fae6c5710bc23e429825844fc5f3a/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/3e27d4875c06f26562caf9d26d01c24d0a6fae6c5710bc23e429825844fc5f3a/hostname",
"HostsPath": "/var/lib/docker/containers/3e27d4875c06f26562caf9d26d01c24d0a6fae6c5710bc23e429825844fc5f3a/hosts",
"LogPath": "",
"Name": "/MyRedis",
"RestartCount": 0,
"Driver": "overlay2",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
}
]
注意:
1、Path后面的值即为该运行容器的位置:
"Path": "docker-entrypoint.sh"
2、HostPath后面的值即为docker容器所在位置:
"HostnamePath": "/var/lib/docker/containers/3e27d4875c06f26562caf9d26d01c24d0a6fae6c5710bc23e429825844fc5f3a/hosts"