docker 容器根目录挂载点

2019-04-25 17:07:47 +08:00
 jeffsun

各位大佬好,有个 docker 的问题,我启动了一个容器 CONTAINER ID 是 0175c5ff2987,通过 df -h 知道这个容器根目录是挂载到 overlay 40G 24G 14G 64% /var/lib/docker/overlay2/eeac18aa0f9bbec7d6b99081ad09dda2e4d0626793de214dde2d154655fa115e/merged。请问如何吧容器 ID 和宿主机挂载点关联呢,比如本地启动了非常多的容器,怎样快速找到某个容器根目录的挂载点。

5794 次点击
所在节点    Docker
2 条回复
senghoo
2019-04-25 17:19:30 +08:00
docker inspect 命令了解下
kingfsen
2019-04-26 18:30:33 +08:00
eeac18aa0f9bbec7d6b99081ad09dda2e4d0626793de214dde2d154655fa115e 这个就是容器层目录,你可以自己写个脚本,通过命令 docker inspect 0175c5ff2987 查找他们之间对应关系,首先应该了解他们之间关联。

https://youendless.com/post/docker_storage_driver/

通过 docker inspect 查出 Id 为镜像 id,7334cfbc206d0f0b1bb7facbef525275a23f4e4d50a37dad72f716255e39b2d6 为容器 id,8985decfb3a78124f061c6d5995a158ca7126c7ccdf4ab7d66853107fb55b4a0 则为挂载点,即容器层目录。

"Id": "7334cfbc206d0f0b1bb7facbef525275a23f4e4d50a37dad72f716255e39b2d6",
"Image": "sha256:94e814e2efa8845d95b2112d54497fbad173e45121ce9255b93401392f538499",
"ResolvConfPath": "/var/lib/docker/containers/7334cfbc206d0f0b1bb7facbef525275a23f4e4d50a37dad72f716255e39b2d6/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/7334cfbc206d0f0b1bb7facbef525275a23f4e4d50a37dad72f716255e39b2d6/hostname",
"HostsPath": "/var/lib/docker/containers/7334cfbc206d0f0b1bb7facbef525275a23f4e4d50a37dad72f716255e39b2d6/hosts",
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/8985decfb3a78124f061c6d5995a158ca7126c7ccdf4ab7d66853107fb55b4a0-init/diff:/var/lib/docker/overlay2/4a00cadd4488f55ad2378a9d2d915dcff733244fc96217b89f827c5f8959b34b/diff:/var/lib/docker/overlay2/e8381b82a136d9cbad47970923b3dec9d6abaaffe08268a326ccf114a4f46d06/diff:/var/lib/docker/overlay2/c47ec19c6123f5a75d9afbe9d9a631ecaa3469ad670bbb2b1b9ce5e64e361c7d/diff:/var/lib/docker/overlay2/9955b547c10c465488960ecba07dcb8ace596c972e3ad8d391afc20cb6aab46b/diff",
"MergedDir": "/var/lib/docker/overlay2/8985decfb3a78124f061c6d5995a158ca7126c7ccdf4ab7d66853107fb55b4a0/merged",
"UpperDir": "/var/lib/docker/overlay2/8985decfb3a78124f061c6d5995a158ca7126c7ccdf4ab7d66853107fb55b4a0/diff",
"WorkDir": "/var/lib/docker/overlay2/8985decfb3a78124f061c6d5995a158ca7126c7ccdf4ab7d66853107fb55b4a0/work"
}

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/558672

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX