#!/bin/bash # Set project-specific prefix to avoid deleting unrelated resources PROJECT_PREFIX="project_mgnt" echo "Starting Docker cleanup for project: $PROJECT_PREFIX..." # Stop and remove containers associated with the project echo "Stopping and removing containers..." docker ps -a --filter "name=$PROJECT_PREFIX" --format "{{.ID}}" | xargs -r docker rm -f # Remove networks associated with the project echo "Removing networks..." docker network ls --filter "name=$PROJECT_PREFIX" --format "{{.ID}}" | xargs -r docker network rm echo "Docker cleanup for project: $PROJECT_PREFIX completed."