Reputation: 5206
version 3 of docker compose allows volumes to be specified. Although I'm looking to use it in a way I'm not sure if it works, can someone provide some insight, here is what I am looking for:
We have a lot of apps, so I'd like to specify the volumes area in one spot
volumes:
app: ./app
microservice: ./microservice
anothermicroservice: ./anothermicroservice
...
services:
app:
...
volumes:
- app/.git:/usr/src/.git
- app/src:/usr/src/src
microservice:
...
volumes:
- microservice/.git:/usr/src/.git
- microservice/src:/usr/src/src
...
This possible? Or anything similar? thanks
Upvotes: 0
Views: 457
Reputation: 489
As far as i know the volume syntax does not offer it.
But i would suggest using environment variables, e.g. with a .env file
$ cat .env
APP=./app
MICROSERVICE=./microservice
$ cat docker-compose.yml
services:
app:
volumes:
- $APP/.git:/usr/src/.git
- $APP/src:/usr/src/src
microservice:
volumes:
- $MICROSERVICE/.git:/usr/src/.git
- $MICROSERVICE/src:/usr/src/src
Upvotes: 1