Closed ulope closed 3 months ago
This is a Docker Compose feature: as a container is recreated for update, the anonymous volumes (volumes declared by Dockerfile VOLUME
) are re-used so you get updated code but don't loose data. Use docker compose up --renew-anon-volumes
if you want such volumes to be renewed
I've never thought this reasoning is sound at all, but especially in the case of volumes_from it makes zero sense to me.
(Insert rant about decision making in docker projects here)
Is there a way to configure the renew-anon-volumes
flag at the project level?
I don't think it's at all reasonable to require operators to remember having to use an obscure and seldom used cli flag on one specific project in order for things to not break.
Description
In a compose stack with service (
A
) that usesvolumes_from
anddepends_on
serviceB
thevolumes_from
retain their old content even when the image tag of serviceB
is changed anddocker compose up
is ran.This seems like a bug. I would expect recreation of both services (which does happen) to also cause the
volumes_from
to update.Steps To Reproduce
Compose file:
data
Dockerfile:VOLUME /data RUN mkdir /data
ARG content RUN echo $content > /data/file
docker build --build-arg content=ONE -t data:v1 . docker build --build-arg content=TWO -t data:v2 .
$ docker compose up -d && docker compose logs work [+] Running 3/3 ✔ Network compose-volfrom-test_default Created 0.0s ✔ Container compose-volfrom-test-data-1 Started 0.2s ✔ Container compose-volfrom-test-work-1 Started 0.2s work-1 | ONE
$ docker compose up -d && docker compose logs work [+] Running 2/2 ✔ Container compose-volfrom-test-data-1 Started 0.3s ✔ Container compose-volfrom-test-work-1 Started 0.2s work-1 | ONE
docker compose down
[+] Running 3/3 ✔ Network compose-volfrom-test_default Created 0.1s ✔ Container compose-volfrom-test-data-1 Started 0.2s ✔ Container compose-volfrom-test-work-1 Started 0.3s work-1 | TWO
Docker Environment
Anything else?
No response