I have a docker-compose.yml file where I'm defining several services, each resulting in an individual container. In short it looks like this:
version: "3.9"
services:
dev_1:
build:
context: .
dockerfile: ./Dockerfile
target: dev_1
volumes:
- type: bind
source: /home/foo
target: /home/bar
dev_2:
build:
context: .
dockerfile: ./Dockerfile
target: dev_2
volumes:
- type: bind
source: /home/foo
target: /home/bar
You can see that for each service I have to bind mount the volume again, by copying the same lines of code. But in my application I have several such folders which I want to mount into all the services, but without having to copy all the lines again and again.
Is there a way to shorten this, e.g. by using the volumes
directive?
So far I only found suggestions to use a shared volume, but this is not practical for me, as such a volume copies the data into the volume. But I have plenty of data (Terrabytes) which I don't want to copy. I just want to bind mount it.
The docker compose version doesn't matter - right now I'm using 3.9
. As long as it works everything is allowed.
Thanks in advance!