13

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?

Jason Leach
  • 3,517
  • 6
  • 36
  • 51

1 Answers1

22

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
Mike Breed
  • 341
  • 1
  • 4
  • 1
    I think this means the file needs to exist on the local file system. I'm looking to mount from a docker volume `docker volume create bla` then mount a file from `bla`. – Jason Leach Feb 12 '19 at 20:24
  • 2
    Ah, I see. I don't see anywhere in the docs where tat is possible. Although, in Kubernetes I think you can mount a subdir of a volume, so I would think that that functionality must exist somewhere. I'll circle back if I come across something. – Mike Breed Feb 15 '19 at 14:02