${image}.tar.gz breaks when $image contains / (e.g., library/hello-world):
imageFile="${image//\//_}" # use existing var, already defined in script
tar -cvC "${dir}" . | gzip -c -9 >"${imageFile}.tar.gz"Unquoted variables break on paths with spaces:
# Bad:
dn $blobRedirect $targetFile
# Good:
dn "$blobRedirect" "$targetFile"Currently only checks curl and jq, missing aria2c, tar, gzip, docker:
for cmd in curl jq aria2c tar gzip docker; do
if ! command -v "$cmd" &>/dev/null; then
echo >&2 "error: \"$cmd\" not found!"
exit 1
fi
doneReplace positional args with flags:
./docker_dn -d output_dir -i hello-world:latest
./docker_dn -h # helpAdd support for other registries:
| Registry | Base URL |
|---|---|
| GCR | gcr.io |
| GHCR | ghcr.io |
| Quay | quay.io |
Detection logic: parse image prefix → set registry base URL.
Track completed layers in a state file. On restart, skip completed layers.
Trap errors and remove partial downloads:
cleanup() { rm -rf "$dir"; }
trap cleanup ERRThe Bash script is already ~480 lines with complex logic (HTTP redirects, JSON parsing, state management). Python would:
- Better error handling
- Easier multi-registry support
- Proper argument parsing with
argparse requestslibrary handles redirects/headers cleanly- Cross-platform without bash version hacks
Read a list of images from a file:
./docker_dn -f images.txt # downloads all images in fileVerify downloaded layer integrity against manifest digests.