Docker sq
Docker Fundamentals - Persisting Data

Disappearing Volumes


Disappearing Volumes

Even though Docker will not normally delete volumes automatically, you can instruct it to remove any volumes mounted to a container once that container exits by providing the -rm flag like so:

$ docker container run --rm -v /data [image]:[tag]

Note: This only works for anonymous volumes. If you provide a name, it will not be deleted.