For production deployment, I don't want shared volumes. So, I have an override file but this does not remove the volumes.
Is there a way to remove shared volumes in an override file? I'd like to avoid having an override just for development, because that seems clunky to use.
This is my docker-compose.yml
:
version: '2'
# other services defined here
services:
web:
build:
context: .
# other configuration
volumes:
- .:${APP_DIR}
And my docker-compose.prod.yml
:
version: '2'
services:
web:
volumes: []
restart: always
When merging a list entry in docker-compose
, it adds new maps but doesn't remove existing volume mappings.
You can implement this by either making dev have the override file, or up to version 2.1 you can extend a common docker file rather than applying overrides which lets to devs point to a single file.
This could be your docker-compose.yml:
version: '2'
# other services defined here
services:
web:
extends:
file: docker-compose.prod.yml
service: web
build:
context: .
restart: no
volumes:
- .:${APP_DIR}
And your docker-compose.prod.yml would contain all the common configuration and prod settings:
version: '2'
services:
web:
# other configuration
restart: always