举杯邀月

Docker 查看容器映射路径信息

摘要:使用docker inspect : 获取容器/镜像的元数据,通过grep搜索Mounts获取映射的路径信息

docker inspect : 获取容器/镜像的元数据。

docker inspect [NAME|ID] | grep Mounts -A 20
1
1

结果:

"Mounts": [
    {
        "Type": "bind",
        "Source": "/home/data/mongo",
        "Destination": "/data/db",
        "Mode": "",
        "RW": true,
        "Propagation": "rprivate"
    },
    {
        "Type": "volume",
        "Name": "274b3b3a467bbaa636cd7bc7027e19121fe8046d8ef56d6efb9f6b9b64f7b7c3",
        "Source": "/var/lib/docker/volumes/274b3b3a467bbaa636cd7bc7027e19121fe8046d8ef56d6efb9f6b9b64f7b7c3/_data",
        "Destination": "/data/configdb",
        "Driver": "local",
        "Mode": "",
        "RW": true,
        "Propagation": ""
    }
],
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

小知识

grep -[A|B|C] n

  • -A 是显示匹配后和它后面的n行
  • -B 是显示匹配行和它前面的n行
  • -C 是匹配行和它前后各n行

作者:举杯邀月

出处: http://www.hug-code.cn/archives/5ff6afdc7b407.html

2020-10-26 标签: docker