docker-compose mounted volume remain
I'm using docker-compose in one of my projects. During development i mount my source directory to a volume in one of my docker services for easy development. At the same time, I have a db service (psql) that mounts a named volume for persistent data storage. I start by solution and everything is working fine $ docker-compose up -d When I check my volumes I see the named and "unnamed" (source volume). $ docker volume ls DRIVER VOLUME NAME local 226ba7af9689c511cb5e6c06ceb36e6c26a75dd9d619360882a1012cdcd25b72 local myproject_data The problem I experience is that, when I do $ docker-compose down ... $ docker volume ls DRIVER VOLUME NAME local 226ba7af9689c511cb5e6c06ceb36e6c26a75dd9d619360882a1012cdcd25b72 local myproject_data both volumes remain. Every time I run $ docker-compose down $ docker-compose up -d a new volume is created for my source mount $ docker volume ls DRIVER VOLUME NAME local 19181286b19c0c3f5b67d7d1f0e3f237c83317816acbdf4223328fdf46046518 local 226ba7af9689c511cb5e6c06ceb36e6c26a75dd9d619360882a1012cdcd25b72 local myproject_data I know that this will not happen on my deployment server, since it will not mount the source, but is there a way to not make the mounted source persistent?
You can use the --rm option in docker run. To use it with docker-compose you can use docker-compose rm -v after stopping your containers with docker-compose stop If you go through the docs about Data volumes , its mentioned that Data volumes persist even if the container itself is deleted. So that means, stopping a container will not remove the volumes it created, whether named or anonymous. Now if you read further down to Removing volumes A Docker data volume persists after a container is deleted. You can create named or anonymous volumes. Named volumes have a specific source form outside the container, for example awesome:/bar. Anonymous volumes have no specific source. When the container is deleted, you should instruct the Docker Engine daemon to clean up anonymous volumes. To do this, use the --rm option, for example: $ docker run --rm -v /foo -v awesome:/bar busybox top This command creates an anonymous /foo volume. When the container is removed, the Docker Engine removes the /foo volume but not the awesome volume.
Docker Swarm - dependencies definition
docker-compose volume not mounted
Exposing sentry service in docker-compose file
Yesod and docker-compose logs in development mode
Docker compose to always deploy using latest image
JHipster - Doubts in the development using Microservices Architecture
Gogs + Drone getsockopt: connection refused
Concourse result keeps loading
Docker-compose: AttributeError: 'module' object has no attribute 'ssl'
scaling a service with docker compose
Docker Compose apparently ignores COMPOSE_FILE
Where does Docker install gems on a mac
What is the difference between docker-machine and docker-compose?
Docker Compose port issue. Cannot launch docker project on localhost
Name an image built from running a docker-compose file
Race conditions after changing names in docker-compose.yml