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?
Asked
Active
Viewed 1.9k times
13
Jason Leach
- 3,517
- 6
- 36
- 51
-
Is this for swarm mode? – BMitch Feb 12 '19 at 22:39
-
Nope. Not swarm mode. – Jason Leach Feb 13 '19 at 05:14
1 Answers
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
-
1I 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
-
2Ah, 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