I'm trying using a setup similar to the following:
version: '3.4'
x-my-volumes: &volumes
- '../src:/var/www/src/:cached'
- '../static:/var/www/static/:cached'
services:
webserver:
build: ./.docker/webserver
volumes:
- *volumes
- './serverlogs/:/var/www/serverlogs/:delegated'
node:
build: ./.docker/node
volumes:
- *volumes
I set up the "shared" volumes in the x-my-volumes
section and give it an anchor of "volumes", which I try to utilise in my services. The main thing, though, is that the services have other volume mounts aside from the shared one. This doesn't work, with errors such as "contains an invalid type, it should be an array
" when doing a docker-compose up
.
Is this possible for docker-compose? I realise I can just copy and paste the volume mounts for each service in my real world scenario its 10+ services and 10+ volumes, so it's a lot of ugly duplication.