Docker挂载目录问题(初学者)
dockerfile编写指定目录挂载会变成匿名挂载
VOLUME ["/home/ruoyi","/home/docker/ruoyi/gateway/logs:/home/ruoyi/logs/ruoyi-gateway"]
匿名挂载一个,指定挂载目录一个,查看挂载发现两个都是匿名的
"Mounts": [
{
"Type": "volume",
"Name": "22c43fc3f90dc1410d628f0c84694f0418e15f4485eb5e6215081410da77a17b",
"Source": "/var/lib/docker/volumes/22c43fc3f90dc1410d628f0c84694f0418e15f4485eb5e6215081410da77a17b/_data",
"Destination": "logs:/home/ruoyi/ruoyi-gateway",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
},
{
"Type": "volume",
"Name": "ca62e97687616f41d65c094ac14bfda5cb8ff1b9bc6370fc8fc2ac1c0eef2353",
"Source": "/var/lib/docker/volumes/ca62e97687616f41d65c094ac14bfda5cb8ff1b9bc6370fc8fc2ac1c0eef2353/_data",
"Destination": "/home/ruoyi",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
}
],
没办法,调整到docker-compose文件里面尝试挂载,发现竟然正常挂载了
volumes:
- ./ruoyi/gateway/logs:/home/ruoyi/logs/ruoyi-gateway
"Mounts": [
{
"Type": "bind",
"Source": "/home/docker/ruoyi/gateway/logs",
"Destination": "/home/ruoyi/logs/ruoyi-gateway",
"Mode": "rw",
"RW": true,
"Propagation": "rprivate"
},
{
"Type": "volume",
"Name": "3f9dc1604787e702bf8d49667f640c6859dde8f7bea515f1cc390f94f27ade8b",
"Source": "/var/lib/docker/volumes/3f9dc1604787e702bf8d49667f640c6859dde8f7bea515f1cc390f94f27ade8b/_data",
"Destination": "/home/ruoyi",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
}
],
想请教各位同学,是什么原因我没学习到的地方?@哪 吒