使用 docker-compose 从卷挂载单个文件 [英] Mount single file from volume using docker-compose
本文介绍了使用 docker-compose 从卷挂载单个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
对于本地开发人员,我需要在 Docker 容器中安装不同的配置文件.这很容易使用命令行 -v $(pwd)/bla.yaml:/location/bla.yaml
.是否可以从 docker-compose
文件中的 volume
(使用 docker volume create bla
创建)执行此操作?
For local dev I need to mount a different config file in a Docker container. This is easy with the command line -v $(pwd)/bla.yaml:/location/bla.yaml
. Is it possible to do this from a volume
(created with docker volume create bla
) in a docker-compose
file?
推荐答案
您应该可以通过绑定安装来实现:
You should be able to do it with a bind mount:
version: "3.2"
services:
app:
image: app:latest
volumes:
- type: bind
source: ./bla.yaml
target: /location/bla.yaml
这篇关于使用 docker-compose 从卷挂载单个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文