forked from tgmti/docker-pdi
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathspoon
executable file
·36 lines (30 loc) · 870 Bytes
/
spoon
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
33
34
35
36
#!/bin/bash
#set -x
# pull in any overrides to IMAGE from the .env file
if [ -f .env ]
then
export $(sed 's/#.*//g' .env)
fi
# Use image name including dockerhub user unless
# overwritten in .env file with a custom local image name
IMAGE=${IMAGE:="tgmti/pdi"}
CONTAINER_NAME=spoon
is_running(){
# Returns (echo) CONTAINER ID if container exists and is running, and
# zero length string otherwise
id=$(docker ps -q -f status=running -f name=$CONTAINER_NAME)
echo $id
}
## main()
# Check container status
CONTAINER_ID=$(is_running)
if [ -z $CONTAINER_ID ] ; then
# Container not running, start it
docker run -it --rm -v /tmp/.X11-unix/:/tmp/.X11-unix/:ro \
-v $(pwd):/jobs \
-e XAUTH=$(xauth list|grep `uname -n` | cut -d ' ' -f5) -e "DISPLAY" \
--name $CONTAINER_NAME \
$IMAGE spoon
else
echo Spoon already running \($CONTAINER_ID\).
fi