-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdload
More file actions
executable file
·37 lines (28 loc) · 888 Bytes
/
dload
File metadata and controls
executable file
·37 lines (28 loc) · 888 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
#!/usr/bin/env bash
#
# Docker Load Images
# To untar a tar file of other files, use tar -xf "archive" -C "outdir"
#
# Load all Docker image tarballs from the current directory into Docker. Uses parallel processing with background jobs.
set -euo pipefail
# Kill all child jobs on Ctrl+C
trap 'echo "Interrupted. Killing all jobs..."; kill 0; exit 1' SIGINT
EXTRACT_DIR="."
mapfile -t TARFILES < <(find "$EXTRACT_DIR" -maxdepth 1 -name '*.tar')
if [[ ${#TARFILES[@]} -eq 0 ]]; then
echo "No .tar files found to load."
exit 1
fi
echo "Found ${#TARFILES[@]} image tarballs. Loading in parallel..."
load_image() {
local tarfile="$1"
echo "Loading image from $tarfile"
docker load -i "$tarfile"
}
# Start all jobs in background
for tar in "${TARFILES[@]}"; do
load_image "$tar" &
done
# Wait for all background jobs to complete
wait
echo "All images loaded successfully!"