V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
jeffsun
V2EX  ›  Docker

docker 容器根目录挂载点

  •  
  •   jeffsun · 2019-04-25 17:07:47 +08:00 · 5759 次点击
    这是一个创建于 2038 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    2 条回复    2019-04-26 18:30:33 +08:00
    senghoo
        1
    senghoo  
       2019-04-25 17:19:30 +08:00   ❤️ 1
    docker inspect 命令了解下
    kingfsen
        2
    kingfsen  
       2019-04-26 18:30:33 +08:00   ❤️ 1
    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"
    }
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2747 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 13:25 · PVG 21:25 · LAX 05:25 · JFK 08:25
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.