gpt4 book ai didi

Docker Compose : Which syntax produces a bind mount, 生成卷

转载 作者:行者123 更新时间:2023-12-01 22:45:42 33 4
gpt4 key购买 nike

在 Docker Compose 文档中,here ,您有以下与 docker-compose.yml 文件的 volumes 部分相关的示例:

volumes:
# (1) Just specify a path and let the Engine create a volume
- /var/lib/mysql

# (2) Specify an absolute path mapping
- /opt/data:/var/lib/mysql

# (3) Path on the host, relative to the Compose file
- ./cache:/tmp/cache

# (4) User-relative path
- ~/configs:/etc/configs/:ro

# (5) Named volume
- datavolume:/var/lib/mysql

哪些语法会生成绑定(bind)挂载,哪些语法会生成docker 卷?在文档的某些地方,这两个概念是严格区分的,但在这个地方它们混合在一起......所以我不清楚。

最佳答案

每当您在评论中看到“音量”时,就会create a volume :所以(1)和(5)。

如果评论里没有卷的话,这是关于a bind mount .

https://docs.docker.com/storage/images/types-of-mounts-bind.png

documentation regarding volumes in docker-compose is here :

Mount host paths or named volumes, specified as sub-options to a service.

You can mount a host path as part of a definition for a single service, and there is no need to define it in the top level volumes key.

But, if you want to reuse a volume across multiple services, then define a named volume in the top-level volumes key.

The top-level volumes key defines a named volume and references it from each service’s volumes list. This replaces volumes_from in earlier versions of the Compose file format. See Use volumes and Volume Plugins for general information on volumes.

关于Docker Compose : Which syntax produces a bind mount, 生成卷,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48873652/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com