Skip to content

Commit

Permalink
adds suport to forward all local environment variables matching a regex
Browse files Browse the repository at this point in the history
  • Loading branch information
jpbochi committed Aug 15, 2016
1 parent 0165548 commit 8395425
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion drun
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ if ! docker inspect --format="{{.Id}}" $IMAGE > /dev/null; then
docker pull $IMAGE
fi

ENV_FILE_OPT=""
if [ -n "$ENVREGEX" ]; then
ENV_FILE=$(echo ".local-env-$$")
env | grep '=' | awk -F '=' '{if($1 ~ /'"$ENVREGEX"'/) print}' > $ENV_FILE
trap "rm $ENV_FILE" EXIT
ENV_FILE_OPT="--env-file=$ENV_FILE"
fi

RM_OPT=${RM_OPT=--rm}

TTY_OPT=""
Expand All @@ -30,5 +38,5 @@ docker run $RM_OPT $TTY_OPT \
-v ~/.ssh:$CONTAINER_HOME/.ssh:ro \
-v ~/.ssh/known_hosts:/root/.ssh/known_hosts:ro \
--net=host \
$EXTRA_OPTS \
$ENV_FILE_OPT $EXTRA_OPTS \
$IMAGE "$@"

0 comments on commit 8395425

Please sign in to comment.