-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatus.sh
More file actions
22 lines (22 loc) · 811 Bytes
/
Copy pathstatus.sh
File metadata and controls
22 lines (22 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
chmod +x status.sh
#!/usr/bin/bash
set -euo pipefail
chmod +x status.sh
echo " =__= Instant Lab status =__= "
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
read -p "Do you want to stop and remove all containers? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Stopping and removing all containers..."
docker stop $(docker ps -q) 2>/dev/null || true
docker rm $(docker ps -a -q) 2>/dev/null || true
echo "All containers stopped and removed."
if docker ps -q | grep -q .; then
echo "Error: Some containers are still running after attempted cleanup."
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
exit 1
fi
else
echo "Ok, Don't worry, no changes made to running containers."
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
fi