Skip to content

Instantly share code, notes, and snippets.

@Tzrlk
Created July 3, 2017 03:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tzrlk/968ca388b65eeca1c37a47f386db8dfc to your computer and use it in GitHub Desktop.
Save Tzrlk/968ca388b65eeca1c37a47f386db8dfc to your computer and use it in GitHub Desktop.
My bullshit script to fetch docker images when having trouble locally.
#!/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
@Tzrlk
Copy link
Author

Tzrlk commented Jul 3, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment