【问题标题】:How can I find where is the docker container directory in host machine?如何找到主机中的 docker 容器目录在哪里?
【发布时间】:2019-02-26 02:53:59
【问题描述】:

我可以通过 docker ps 找到 docker 容器 id

我也知道容器存放在/var/lib/docker/containers/下

docker ps 返回的值与任何目录的 id 都不匹配。

那么我怎样才能找到哪个目录存储了哪些容器文件呢?

【问题讨论】:

    标签: docker docker-compose


    【解决方案1】:

    您可以使用以下命令获取容器(容器 ID)使用的所有挂载的 JSON 输出。 输出 json 中“Source”键的值将是主机目录

    docker inspect -f '{{ json .Mounts }}' <container-Id>
    

    通过管道输出到 jqpython json 模块来美化 json:

    docker inspect -f '{{ json .Mounts }}' <container-Id> | python -m json.tool
    docker inspect -f '{{ json .Mounts }}' <container-Id> | jq
    

    【讨论】:

      猜你喜欢
      • 2014-06-19
      • 1970-01-01
      • 1970-01-01
      • 2013-03-19
      • 1970-01-01
      • 1970-01-01
      • 2019-07-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多