-
Notifications
You must be signed in to change notification settings - Fork 24
/
run.sh
executable file
·31 lines (27 loc) · 958 Bytes
/
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
#!/bin/sh
version_gt() { test "$(echo "$@" | tr " " "\n" | sort -V | tail -n 1)" = "$1"; }
docker_version=$(docker version | grep 'Client version' | awk '{split($0,a,":"); print a[2]}' | tr -d ' ')
# Docker 1.3.0 or later is required for --device
if ! version_gt "${docker_version}" "1.2.0"; then
echo "Docker version 1.3.0 or greater is required"
exit 1
fi
if test $# -lt 1; then
# Get the latest opengl-nvidia build
# and start with an interactive terminal enabled
args="-i -t $(docker images | grep ^opengl-nvidia | head -n 1 | awk '{ print $1":"$2 }')"
else
# Use this script with derived images, and pass your 'docker run' args
args="$@"
fi
XSOCK=/tmp/.X11-unix
XAUTH=/tmp/.docker.xauth
touch $XAUTH
xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
docker run \
-v $XSOCK:$XSOCK:rw \
-v $XAUTH:$XAUTH:rw \
--device=/dev/dri/card0:/dev/dri/card0 \
-e DISPLAY=$DISPLAY \
-e XAUTHORITY=$XAUTH \
$args