-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclean-up-docker.bash
More file actions
executable file
·39 lines (29 loc) · 1002 Bytes
/
clean-up-docker.bash
File metadata and controls
executable file
·39 lines (29 loc) · 1002 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
set -e # Exit on any error
echo "🧹 Docker Cleanup Script"
echo "======================="
echo "⚠️ WARNING: This will remove ALL Docker resources!"
echo "This includes containers, images, volumes, and networks from ALL projects."
echo ""
read -p "Are you sure you want to continue? (y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Cancelled."
exit 1
fi
echo "🛑 Stopping and removing containers from this project..."
docker compose down -v
echo "🗑️ Removing all Docker containers..."
docker container prune -f
echo "🗑️ Removing all Docker images..."
docker image prune -a -f
echo "🗑️ Removing all Docker volumes..."
docker volume prune -f
echo "🗑️ Removing all Docker networks..."
docker network prune -f
echo "🗑️ Clearing Docker build cache..."
docker builder prune -a -f
echo "🧹 Complete system cleanup..."
docker system prune -a -f --volumes
echo "🚀 Building and starting services..."
docker compose up --build