-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker_run.sh
39 lines (38 loc) · 1.22 KB
/
docker_run.sh
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
37
38
39
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
viskit_port=$("$DIR/findport.sh" 5000 1)
xhost=xhost
if hash nvidia-docker 2>/dev/null; then
docker=nvidia-docker
else
docker=docker
fi
if [[ $(uname) == 'Darwin' ]]; then
# if xhost not defined, check
if ! hash $xhost 2>/dev/null; then
xhost=/opt/X11/bin/xhost
if [ ! -f $xhost ]; then
echo "xhost not found!"
exit
fi
fi
ip=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')
$xhost + $ip >/dev/null
$docker run --rm -p $viskit_port:$viskit_port -e VISKIT_PORT=$viskit_port \
-e DISPLAY=$ip:0 \
-v "$DIR":/root/code/bootcamp_pg \
-ti dementrock/deeprlbootcamp \
${1-/bin/bash} "${@:2}"
$xhost - $ip >/dev/null
elif [[ $(uname) == 'Linux' ]]; then
$xhost +local:root >/dev/null
$docker run --rm -p $viskit_port:$viskit_port -e VISKIT_PORT=$viskit_port \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v "$DIR":/root/code/bootcamp_pg \
-ti dementrock/deeprlbootcamp \
${1-/bin/bash} "${@:2}"
$xhost -local:root >/dev/null
else
echo "This script only supports macOS or Linux"
fi