Files
linux-8.2/remove-containers-and-data.sh
2024-12-12 00:20:41 +02:00

32 lines
850 B
Bash
Executable File

#!/bin/bash
echo "This will stop and remove all Docker containers, volumes, plugins, prune the system, and delete STACK_VERSION.txt."
read -p "Are you sure you want to proceed? Type 'yes' or 'y' to confirm: " confirm
if [[ "$confirm" == "yes" || "$confirm" == "y" ]]; then
echo "Stopping all containers..."
docker stop $(docker ps -a -q)
echo "Removing all containers..."
docker rm $(docker ps -a -q)
echo "Removing all volumes..."
docker volume rm $(docker volume ls -q)
echo "Removing all plugins..."
docker plugin rm $(docker plugin ls -q)
echo "Pruning all volumes..."
docker volume prune -f
echo "Pruning the system..."
docker system prune -f
echo "Deleting STACK_VERSION.txt..."
rm -f STACK_VERSION.txt
echo "All operations completed."
else
echo "Operation canceled."
fi