-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathload-docker-images.sh
More file actions
executable file
·67 lines (56 loc) · 1.77 KB
/
load-docker-images.sh
File metadata and controls
executable file
·67 lines (56 loc) · 1.77 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env bash
# Load Docker images from saved tar files for offline use
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
IMAGES_DIR="${SCRIPT_DIR}/docker-images"
echo "=== Loading Docker Images from Offline Archive ==="
# Check if images directory exists
if [[ ! -d "$IMAGES_DIR" ]]; then
echo "❌ Images directory not found: $IMAGES_DIR"
echo "Run ./save-docker-images.sh first to create the archive"
exit 1
fi
# Check if there are any tar files
if ! ls "$IMAGES_DIR"/*.tar >/dev/null 2>&1; then
echo "❌ No .tar files found in: $IMAGES_DIR"
echo "Run ./save-docker-images.sh first to save images"
exit 1
fi
echo "Found Docker image archives:"
ls -lh "$IMAGES_DIR"/*.tar
echo ""
# Load each tar file
loaded_count=0
failed_count=0
for tarfile in "$IMAGES_DIR"/*.tar; do
if [[ -f "$tarfile" ]]; then
filename=$(basename "$tarfile")
echo "Loading: $filename"
if docker load -i "$tarfile"; then
echo " ✅ Loaded successfully"
((loaded_count++))
else
echo " ❌ Failed to load $filename"
((failed_count++))
fi
echo ""
fi
done
echo "=== Summary ==="
echo "✅ Successfully loaded: $loaded_count images"
if [[ $failed_count -gt 0 ]]; then
echo "❌ Failed to load: $failed_count images"
fi
echo ""
echo "📋 All loaded Docker images:"
docker images --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}\t{{.CreatedAt}}"
if [[ $failed_count -gt 0 ]]; then
exit 1
else
echo ""
echo "🎉 All images loaded successfully!"
echo ""
echo "Quick start commands:"
echo " 🚀 Start all services: docker-compose up"
echo " 🔍 View all images: docker images"
echo " 🐳 Run any container: docker run -it --rm <image_name>"
fi