Created
July 24, 2018 15:43
-
-
Save nonkr/44b1ee0a89ce5ffcfb601123c54dbcdf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
IMAGES=$(docker images | awk '{print $1":"$2}') | |
echo "Saving images to tar files." | |
for image in ${IMAGES}; do | |
if [ ${image} != "REPOSITORY:TAG" ];then | |
echo "==> Saving ${image}......\c" | |
tar=$(echo -n ${image} | base64) | |
docker save -o ${tar}.tar ${image} | |
echo "Done." | |
fi | |
done | |
echo "All images saved, ready to exit docker application." | |
osascript -e 'quit app "Docker"' | |
echo "Stopping.\c" | |
while docker info >/dev/null 2>&1; do | |
echo ".\c" | |
sleep 1 | |
done; | |
echo "done.\n" | |
rm ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2 | |
echo "Reopen docker application.\c" | |
open -a Docker | |
until docker info >/dev/null 2>&1; do | |
echo ".\c" | |
sleep 1 | |
done; | |
echo "done.\n" | |
echo "Reload all images." | |
for image in ${IMAGES}; do | |
if [ ${image} != "REPOSITORY:TAG" ];then | |
tar=$(echo -n ${image} | base64) | |
echo "==> Loading ${image}......\c" | |
docker load -q -i ${tar}.tar || exit 1 | |
echo "Done." | |
fi | |
done | |
echo "All finished." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment