为了替换版本 2 中的 volumes_from:
指令(针对 helpyio ),我尝试了这个,但出了点问题。
version: "3"
services:
frontend:
...
volumes:
- myVolume:/var/www:ro
backend:
...
volumes:
- myVolume:/var/www
volumes:
myVolume:
driver: local
driver_opts:
type: none
device: "/my/local/absolute/path/"
o: bind
我有这样的错误
ERROR: for frontend: Cannot create container for service frontend: failed to mount local volume: mount /my/local/absolute/path/:/var/www, flags: 0x1000: no such file or directory
我还在 volumes:
选项中尝试了一些变体,但没有成功。最后一件事,我不想手动创建这个本地目录。
我肯定会遗漏一些东西,但看不到什么...有人对此用例有解决方案吗?
非常感谢
最佳答案
没有理由让您的 docker-compose.yml
变得那么复杂。你可以简单地这样做:
version: "3"
services:
frontend:
...
volumes:
- /my/local/absolute/path/:/var/www:ro
backend:
...
volumes:
- /my/local/absolute/path/:/var/www
关于 docker 撰写 : absolute path for shared volumes in version 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59054466/