![](/img/trans.png)
[英]Docker-compose shared volume between containers but that has a path in host
[英]How to specify volume host path in docker-compose?
我想在多个容器之间共享一个卷,并在主机上指定这个卷的路径。
我使用了以下设置:
version: '3'
services:
service1:
image: image1
volumes:
- volume1:/volume1
service2:
image: image2
volumes:
- volume1:/volume1
volumes:
volume1:
driver: local # meaning?
driver_opts:
o: bind # meaning?
type: none # meaning?
device: /volume1 # the path on the host
但我不确定driver: local
、 type: none
和o: bind
选项。
我想要一个常规卷(比如不指定任何driver
或driver_opts
),只是能够指定主机上的路径。
您正在寻找bind mount 。 指定volumes
键意味着您正在 Docker 机器中创建一个用于持久存储的卷。 尽管名称如此,但volume
不一定与volumes
相关。
使用类似的东西:
version: '3'
services:
service1:
image: image1
volumes:
- type: bind # Host and Docker machines have identical views to the same directory; changes propagate both ways
source: . # Host machine directory to mount
target: /app # Docker machine directory to be mapped to
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.