-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfix-docker-zombies.sh
More file actions
executable file
·27 lines (20 loc) · 956 Bytes
/
fix-docker-zombies.sh
File metadata and controls
executable file
·27 lines (20 loc) · 956 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
#!/bin/bash
echo "🚫 Searching for zombie Docker containers (Django/Playit)..."
# Dynamically find container names containing 'django' or 'playit'
CONTAINERS=$(docker ps -a --format '{{.Names}}' | grep -E 'django|playit')
if [ -z "$CONTAINERS" ]; then
echo "✅ No Django or Playit containers found."
else
for name in $CONTAINERS; do
PID=$(docker inspect --format '{{ .State.Pid }}' "$name" 2>/dev/null)
if [ -n "$PID" ] && [ "$PID" -ne 0 ]; then
echo "🧟 Killing container '$name' (PID: $PID)..."
sudo kill -9 "$PID" || echo "⚠️ Failed to kill PID $PID"
fi
echo "🗑️ Removing container '$name'..."
sudo docker rm -f "$name" || echo "⚠️ Failed to remove $name"
done
fi
echo "🔻 Running docker-compose down just in case..."
sudo docker-compose down || echo "⚠️ docker-compose down failed"
echo "✅ Cleanup complete. All containers shut down cleanly."