What is the Docker way to clean up all stopped Docker containers but retain data-only containers?
docker rm $(docker ps -qa -f status=exited)
removes these too!How to clean up the according images?
In general there is no definitive way to distinguish data-only
from other containers. If you wish them to survive your cleansing, you could probably design a certain name scheme and have more elaborate scripts that wouldn't remote containers with name, say, starting with data-
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With