-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsandbox.sh
More file actions
executable file
·32 lines (25 loc) · 1.05 KB
/
sandbox.sh
File metadata and controls
executable file
·32 lines (25 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
xhost +local:root # for the lazy and reckless
SHAPELY_IMAGE_NAME="shapely"
SHAPELY_VERSION="latest"
CONTAINER_NAME="shapely_sandbox"
DOCKER_ARGS='-it'
#DOCKER_ARGS+=" --user=1000:1000"
DOCKER_ARGS+=" --env=DISPLAY"
DOCKER_ARGS+=" --env=QT_X11_NO_MITSHM=1"
DOCKER_ARGS+=" -v /tmp/.X11-unix:/tmp/.X11-unix:rw"
DOCKER_ARGS+=" -v $PWD:/workspace"
DOCKER_ARGS+=" -w /workspace"
DOCKER_ARGS+=" --name $CONTAINER_NAME"
CMD="bash"
EXISTING_STOPPED_CONTAINER=$(docker ps --all --quiet --filter "name=$CONTAINER_NAME" --filter "exited=0")
EXISTING_RUNNING_CONTAINER=$(docker ps --all --quiet --filter "name=$CONTAINER_NAME" --filter "status=running")
echo $EXISTING_STOPPED_CONTAINER
echo $EXISTING_RUNNING_CONTAINER
if [ -z $EXISTING_STOPPED_CONTAINER ] && [ -z $EXISTING_RUNNING_CONTAINER ]; then
docker run $DOCKER_ARGS ${SHAPELY_IMAGE_NAME}:${SHAPELY_VERSION} $CMD
elif [ -z $EXISTING_RUNNING_CONTAINER ]; then
docker start $EXISTING_STOPPED_CONTAINER
docker exec -ti $EXISTING_STOPPED_CONTAINER bash
else
docker exec -ti $EXISTING_RUNNING_CONTAINER bash
fi