Following script could help remove all the running Docker containers. Save the script in a file namely, delContainers.sh. Change the permission using command such as “chmod u+x delContainers.sh”. Execute the script using the command such as ./delContainers.sh. And, that is it. it would help you delete all the containers.
function clearContainers () { CONTAINER_IDS=$(docker ps -aq) if [ -z "$CONTAINER_IDS" -o "$CONTAINER_IDS" == " " ]; then echo "---- No containers available for deletion ----" else docker rm -f $CONTAINER_IDS fi } clearContainers
Latest posts by Ajitesh Kumar (see all)
- Mean Squared Error vs Cross Entropy Loss Function - April 28, 2024
- Cross Entropy Loss Explained with Python Examples - April 28, 2024
- Logistic Regression in Machine Learning: Python Example - April 26, 2024
Leave a Reply