Skip to content

Instantly share code, notes, and snippets.

@dcreager
Created July 10, 2015 14:26
Show Gist options
  • Save dcreager/5b66e8bfeeb4a4695ec3 to your computer and use it in GitHub Desktop.
Save dcreager/5b66e8bfeeb4a4695ec3 to your computer and use it in GitHub Desktop.
Script to run a docker image with $PWD available inside and with SSH forwarding
#!/bin/sh
if [ -n "$SSH_AUTH_SOCK" ]; then
SSH_AUTH_DIR=`dirname $SSH_AUTH_SOCK`
SSH_OPTS="-v $SSH_AUTH_DIR:$SSH_AUTH_DIR -e SSH_AUTH_SOCK=$SSH_AUTH_SOCK"
fi
IMAGE=$1
shift
docker run \
-i -t --rm \
$SSH_OPTS \
-v "$PWD":/outside \
-w /outside \
$IMAGE \
/bin/bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment