Reputation: 8530
I want to override my volume in my production environment as I don't need it there (have it on my local environment for faster development). However, adding a docker-compose.override.yml file doesn't actually "remove" my volumes (resulting in an error).
This is my docker-compose.yml file
version: '3.7'
services:
app:
image: USERNAME/PROJECT_NAME
container_name: PROJECT_NAME
volumes:
- ./:/usr/src/app
...
This is my docker-compose.override.yml file
version: '3.7'
services:
app:
volumes: []
Any reason for this behaviour or alternative approaches?
Upvotes: 0
Views: 1810
Reputation: 263906
An override in compose merges the values of the override file on top of the original file, but that doesn't unset values from the original. Merging an array with an empty array is that original array. You'll likely want to switch the logic, and have an override compose file for the environment with the volume, and the original compose file for the environment without any volumes.
Upvotes: 3