1、查看Docker Volume内幕
查看名为todo-db
的docker volume的信息。
$ docker volume create todo-db
todo-db
$ docker volume inspect todo-db
[
{
"CreatedAt": "2023-02-28T07:11:09Z",
"Driver": "local",
"Labels": {},
"Mountpoint": "/var/lib/docker/volumes/todo-db/_data",
"Name": "todo-db",
"Options": {},
"Scope": "local"
}
]
Mountpoint
是该volume在宿主机的文件系统的路径
在Mac上,Docker是运行在一个LinuxKit的虚拟机里面的,所以Docker的宿主机是LinuxKit,
所以进入Mac版Docker LinuxKit虚拟机查看:
$ docker run -it --rm --privileged --pid=host alpine:edge nsenter -t 1 -m -u -n -i sh
/ # ls /var/lib/docker/volumes/todo-db/_data
hello.txt
参考: