Created
July 3, 2017 03:56
-
-
Save Tzrlk/968ca388b65eeca1c37a47f386db8dfc to your computer and use it in GitHub Desktop.
My bullshit script to fetch docker images when having trouble locally.
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
#!/usr/bin/env bash | |
IMAGE="${1}" | |
REMOTE_HOST=${2} # You may want to set a default for this | |
REMOTE_USER=${3} # and this | |
REMOTE_SSH="${REMOTE_USER}@${REMOTE_HOST}" # Add a fqdn to the end if it helps | |
REMOTE_FILE="/home/${REMOTE_USER}/export.tar" | |
LOCAL_FILE="$(pwd)/export.tar" | |
ssh "${REMOTE_SSH}" "docker pull ${IMAGE}" || exit 1 | |
ssh "${REMOTE_SSH}" "docker save ${IMAGE} -o ${REMOTE_FILE}" || exit 1 | |
scp "${REMOTE_SSH}:${REMOTE_FILE}" "${LOCAL_FILE}" || exit 1 | |
docker load -i "${LOCAL_FILE}" || exit 1 | |
rm -f "${LOCAL_FILE}" || exit 1 | |
ssh "${REMOTE_SSH}" "rm -f ${REMOTE_FILE}" || exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Obviously this can be greatly improved, but it's a good start when running
docker pull
keeps failing part-way-through because your corporate network has annoying restrictions on desktop-related network operations.