killTestcontainers.sh
1 #!/bin/bash 2 3 # Find all Docker containers with the label "org.testcontainers=true" 4 containers=$(docker ps -q -f "label=org.testcontainers=true") 5 6 # Check if there are any containers to stop 7 if [ -z "$containers" ]; then 8 echo "No containers with label 'org.testcontainers=true' found." 9 else 10 # Stop the containers 11 echo "Stopping containers..." 12 docker stop $containers 13 14 # Remove the containers 15 echo "Removing containers..." 16 docker rm $containers 17 18 echo "Containers have been stopped and removed." 19 fi