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 &amp;quot;$CONTAINER_IDS&amp;quot; -o &amp;quot;$CONTAINER_IDS&amp;quot; == &amp;quot; &amp;quot; ]; then echo &amp;quot;---- No containers available for deletion ----&amp;quot; else docker rm -f$CONTAINER_IDS
fi
}
clearContainers