版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_34173549/article/details/80400454
报错:
[root@ops-ip-statistic ~]# docker inspect -f {{.Volumes}} volume-test1
Template parsing error: template: :1:2: executing "" at <.Volumes>: map has no entry for key "Volumes"
- 1
- 2
- 3
解决:
1,使用 “.Config.Volumes” 替换 “.Volumes”
[root@ops-ip-statistic ~]# docker inspect -f {{.Config.Volumes}} volume-test1
map[/data:{}]
- 1
- 2
显示为空,此法 在此不可行
2,直接看容器的所有信息 再grep
[root@ops-ip-statistic _data]# docker inspect volume-test1 | grep Mounts -A 10
"Mounts": [
{
"Name": "0a3d70900bd0fa46c797f7aa7ff5176b7f6a5a798b6a282cd6c532facfd24925",
"Source": "/var/lib/docker/volumes/0a3d70900bd0fa46c797f7aa7ff5176b7f6a5a798b6a282cd6c532facfd24925/_data",
"Destination": "/data",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
}
],
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
找到对应的目录是:
/var/lib/docker/volumes/0a3d70900bd0fa46c797f7aa7ff5176b7f6a5a798b6a282cd6c532facfd24925/_data
- 1
进入容器中创建一个文件:
[root@nginx data]# echo 123 >a
[root@nginx data]# cat a
123
- 1
- 2
- 3
在宿主机的对应的目录中查看:
[root@ops-ip-statistic _data]# cd /var/lib/docker/volumes/0a3d70900bd0fa46c797f7aa7ff5176b7f6a5a798b6a282cd6c532facfd24925/_data
[root@ops-ip-statistic _data]# cat a
123
- 1
- 2
- 3
可行!