#!/bin/tcsh -f set image_name=centos7:sim-recon alias docker 'sudo /usr/bin/docker' # Check if a running container already exists for this image. # Use it if so, otherwise launch a new container. set container_id=`docker ps -a | grep $image_name | awk '{print $1}'` if ( $container_id == "" ) then echo "No container exists for image $image_name. Creating a new one ..." # Create new container that stays up forever until explicity stopped # Map a few directories over to the container docker run -d \ -v ${HOME}:/home_host/$USER \ -v /tmp:/tmp_host \ -v /scratch:/scratch \ -v /gluex:/gluex \ -v /gluonwork1:/gluonwork1 \ -v /gluonraid2:/gluonraid2 \ -v /gluonraid3:/gluonraid3 \ -v /lustre:/lustre \ $image_name sleep infinity # Get container id and add user and "halld-1" group to it set container_id=`docker ps -a | grep $image_name | awk '{print $1}'` docker exec $container_id groupadd -g 267 halld-1 docker exec $container_id adduser -u `id -u` -g 267 -s /bin/tcsh $USER docker exec -it -u `id -u` $container_id ln -s /docker/dot_tcshrc /home/$USER/.tcshrc docker exec -it -u `id -u` $container_id ln -s /home_host/$USER /home/$USER/home_host endif # Get container id if ( $container_id == "" ) then echo "Problem creating container!" else #docker exec -it -e DISPLAY=`hostname` $container_id tcsh docker exec -it -u `id -u` $container_id tcsh endif