Remove a named volume with docker-compose?
There's no way to target the removal of a specific named volume with the
docker-compose cli. Instead this can be achieved using the
docker cli. See the docs.
docker volume ls to find the name of specific volume.
Remove the volume using
docker volume rm VOLUME_NAME. You will need to have stopped and removed containers using the volume.
An example approach:
# Stop and remove container's using the target volume docker-compose stop NAME_OF_CONTAINER # We need the force flag, "-f", as the container is still bound to the volume docker-compose rm -f NAME_OF_CONTAINER # Next find your volume name in the following list docker volume ls # Finally remove the volume docker volume rm VOLUME_NAME
docker-compose down -v
removes all volumes attached. See the docs