How can I prevent docker-compose up
from copying saved volumes from the previous session into a container? In effect, I want Docker Compose to behave like docker run
which discards the contents of private volumes when its container exits.
How can I prevent docker-compose up
from copying saved volumes from the previous session into a container? In effect, I want Docker Compose to behave like docker run
which discards the contents of private volumes when its container exits.
It seems that no option exists to prevent
docker-compose up
from using volumes from a previous session. The best alternative I could think of is to stop the containers and then remove the containers and their private volumes:Note that unlike
docker-compose down --volumes
, this preserves named volumes.Try using
docker-compose up --force-recreate
. See https://docs.docker.com/compose/reference/up/ for more details.I think that problem is that
docker-compose up
is re-using existing containers, so existing volumes are re-used as well (there is no actual copying of the data).