Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mount single file from volume using 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?

like image 934
Jason Leach Avatar asked Feb 12 '19 19:02

Jason Leach


People also ask

Can a Docker volume be a single file?

The Docker CLI provides the –mount and –volume options with a run command to bind a single file or directory. Both flags work similarly but have different syntaxes. As a result, we can use them interchangeably.


1 Answers

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
like image 179
Mike Breed Avatar answered Sep 21 '22 13:09

Mike Breed