1. 刪除包含特定字符串的Containers
舉例:刪除返回結果中包含 “demo” 字樣的Containers,且不影響其餘Containers。
~$ docker rm $(docker ps -a | grep 'demo'| awk '{print $1 }')
2. 刪除包含特定字符串的Images
舉例:刪除返回結果中包含 “demo” 字樣的所有Images,且不影響其餘Images。
~$ docker rmi $(docker images -a | grep 'demo'| awk '{print $1 }')
參考資料
[1] https://linuxconfig.org/remove-all-containners-based-on-docker-image-name
[2] https://www.digitalocean.com/community/tutorials/how-to-remove-docker-images-containers-and-volumes