Skip to content

Instantly share code, notes, and snippets.

@aleguerra05
Created June 27, 2019 19:09
Show Gist options
  • Save aleguerra05/5f872011d111d560af741db54235ff6c to your computer and use it in GitHub Desktop.
Save aleguerra05/5f872011d111d560af741db54235ff6c to your computer and use it in GitHub Desktop.
Esport and Import all docker images.
--EXPORT
docker save $(docker images -q) -o /path/to/save/mydockersimages.tar
--
docker images | awk '{if ($1 ~ /^(openshift|centos)/) print $1 " " $2 " " $3 }' | tr -c "a-z A-Z0-9_.\n-" "%" | while read REPOSITORY TAG IMAGE_ID
do
echo "== Saving $REPOSITORY $TAG $IMAGE_ID =="
docker save -o /path/to/save/$REPOSITORY-$TAG-$IMAGE_ID.tar $IMAGE_ID
done
--IMPORT
docker load -i /path/to/save/mydockersimages.tar
--
while read REPOSITORY TAG IMAGE_ID
do
echo "== Tagging $REPOSITORY $TAG $IMAGE_ID =="
docker tag "$IMAGE_ID" "$REPOSITORY:$TAG"
done < mydockersimages.list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment