使用docker-compose从卷挂载单个文件 [英] Mount single file from volume using docker-compose

查看:1213
本文介绍了使用docker-compose从卷挂载单个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于本地开发人员,我需要在Docker容器中挂载其他配置文件。使用命令行 -v $ {pwd)/bla.yaml:/location/bla.yaml 很容易。是否可以从 volume (使用 docker volume create bla 创建的)执行此操作> docker-compose 文件?

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆