Skip to content

Instantly share code, notes, and snippets.

@ewindisch
Last active November 24, 2015 20:52
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 ewindisch/45c47b60c7034f9e6662 to your computer and use it in GitHub Desktop.
Save ewindisch/45c47b60c7034f9e6662 to your computer and use it in GitHub Desktop.
function dockerfallback {
[ $? -eq 127 ] || return
IFS=', ' read -r -a ARGS <<< "$BASH_COMMAND"
if (docker images -q "$USER/${ARGS[0]}" 2>&1 >/dev/null); then
docker run --rm -it $USER/${ARGS[@]}
fi
}
trap dockerfallback ERR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment