Open g-kartik opened 8 months ago
Only services indeed get recreated after configuration change has been detected. We could do the same for volumes (while bit more complex to manage regarding lifecycle) but this would mean user data would be deleted, which could be an issue.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as not stale anymore due to the recent activity.
@ndeloof Can we keep the old volumes without deleting and mount the new one?
@g-kartik nope, as volume name is unique we have no option to keep the existing one
I did not understand. The issue is regarding when volume names changes in the compose file, the docker compose up
command should unmount (but not delete) the old volume and mount the new volume. If we again change back to old volume then it should get mounted again and reused. There is no issue of uniqueness here.
right, my bad, have been reading too fast.
The issue here is that compose compares actual container state with desired state only based on service.foo
yaml section, where volume is referenced as cvat_db
in the reported example. The fact actual volume name is updated (or any other configuration attribute) isn't detected. A comparable issue is https://github.com/docker/compose/issues/11900
IMHO we miss a global mechanism to detect volume/config/secrets/networks do not run with desired state, and recreate services accordingly
Description
I want postgres database to use separate data volumes for each git branch. I am passing the
CURRENT_GIT_BRANCH
value through.env
file.Here is the docker compose file
When executing
docker compose up
for the first time withCURRENT_GIT_BRANCH
asdevelop
, the container gets correctly mounted with the volumecvat_db_develop
.With a new value for the
CURRENT_GIT_BRANCH
, sayfeature
, the volumecvat_db_feature
gets created successfully, however the container volume mount source still refers to the oldcvat_db_develop
volume.The expected behavior is that by changing the name of the named volume:
Compose Version
Docker Environment
Anything else?
No response