Skip to content

Commit

Permalink
Saving.
Browse files Browse the repository at this point in the history
  • Loading branch information
lemire committed Aug 25, 2021
1 parent 0b37229 commit 835cde7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
3 changes: 1 addition & 2 deletions run-docker-station
Expand Up @@ -26,9 +26,8 @@ SSHPARAM=""

docker image inspect $container_name >/dev/null 2>&1 || ( echo "instantiating the container" ; docker build --no-cache -t $container_name -f $SCRIPTPATH/Dockerfile --build-arg USER_NAME="$USER" --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) . )

# We run in privileged mode to have access to performance counters.
if [ -t 0 ]; then DOCKER_ARGS=-it; fi
docker run --rm $DOCKER_ARGS -h $container_name --privileged $SSHPARAM -v $(pwd):$(pwd):Z -w $(pwd) $container_name sh -c "$COMMAND"
docker run --rm $DOCKER_ARGS -h $container_name $SSHPARAM -v $(pwd):$(pwd):Z -w $(pwd) $container_name sh -c "$COMMAND"



34 changes: 34 additions & 0 deletions run-privileged-docker-station
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

if [ -z "$1" ]
then
echo "The run-docker-station script takes a command as a argument. E.g., try ./run-docker-station 'ls' "
exit 1
fi

set -o noglob
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"

COMMAND=$@



container_name=${CONTAINER_NAME:-"programming_station-for-$USER"}

command -v docker >/dev/null 2>&1 || { echo >&2 "Please install docker. E.g., go to https://www.docker.com/products/docker-desktop Type 'docker' to diagnose the problem."; exit 1; }

docker info >/dev/null 2>&1 || { echo >&2 "Docker server is not running? type 'docker info'."; exit 1; }

SSHPARAM=""
[ -e "${SSH_AUTH_SOCK}" ] && SSHPARAM="--volume /run/host-services/ssh-auth.sock:/run/host-services/ssh-auth.sock --env SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock"
[ -e "${HOME}/.ssh" ] && SSHPARAM="--volume ${HOME}/.ssh:/home/$USER/.ssh:ro"


docker image inspect $container_name >/dev/null 2>&1 || ( echo "instantiating the container" ; docker build --no-cache -t $container_name -f $SCRIPTPATH/Dockerfile --build-arg USER_NAME="$USER" --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) . )

# We run in privileged mode to have access to performance counters.
if [ -t 0 ]; then DOCKER_ARGS=-it; fi
docker run --rm $DOCKER_ARGS -h $container_name --privileged $SSHPARAM -v $(pwd):$(pwd):Z -w $(pwd) $container_name sh -c "$COMMAND"



0 comments on commit 835cde7

Please sign in to comment.