Skip to content

Instantly share code, notes, and snippets.

@inceabdullah
Created December 14, 2023 12:23
Show Gist options
  • Save inceabdullah/ee60e600d48271adf47826077e89fa32 to your computer and use it in GitHub Desktop.
Save inceabdullah/ee60e600d48271adf47826077e89fa32 to your computer and use it in GitHub Desktop.
Tar Dump All Docker Images From List
#!/bin/bash
# cat imagelist.txt |bash THISSCRIPT.sh
# imagelist.txt:
# nginx:latest
# user/image:tag
color_echo() {
local color='\033[1;33m'
local message=$1
local BOLD='\033[31m'
local RESET='\033[0m'
echo -e "${BOLD}${color}${message}${RESET}"
}
# DUMP_DIR= # dump dir def: $PWD
if [ -z "$DUMP_DIR" ] ;
then
DUMP_DIR=$PWD
fi
while IFS= read -r IMAGE_TAGGED; do
echo >&2 "image tagged: ${IMAGE_TAGGED}"
IMAGE_TAGGED_FILENAME_SAFE=`echo "$IMAGE_TAGGED" |tr -c "a-z A-Z0-9_.\n-" "%"`
color_echo "== Saving $IMAGE_TAGGED =="
docker save -o $DUMP_DIR/$IMAGE_TAGGED_FILENAME_SAFE.tar $IMAGE_TAGGED
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment