forked from gwjensen/SnakeStrikeDocker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontainer.sh
53 lines (47 loc) · 1.31 KB
/
container.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash -e
# Parameters
IMAGE=hostmot2-builder
NAME=${IMAGE}
TOPDIR="$(readlink -f $(dirname $0))"
UID_GID=`id -u`:`id -g`
# Check for existing containers
EXISTING="$(docker ps -aq --filter=name=${NAME}\$)"
if test -n "${EXISTING}"; then
# Container exists; is it running?
RUNNING=$(docker inspect ${EXISTING} | awk '/"Running":/ { print $2 }')
if test "${RUNNING}" = "false,"; then
# Remove stopped container
echo docker rm ${EXISTING}
elif test "${RUNNING}" = "true,"; then
# Container already running; error
echo "Error: container '${NAME}' already running" >&2
exit 1
else
# Something went wrong
echo "Error: unable to determine status of " \
"existing container '${EXISTING}'" >&2
exit 1
fi
fi
test -d "${TOPDIR}/Xilinx" || mkdir -p "${TOPDIR}/Xilinx"
set -x
#exec docker run --rm \
# -it --privileged \
# -u "$UID_GID" \
# -v /tmp/.X11-unix:/tmp/.X11-unix \
# -v /dev/dri:/dev/dri \
# -v "$HOME":"$HOME" \
# -v "$TOPDIR":"$TOPDIR" \
# -v "$TOPDIR/Xilinx":"/opt/Xilinx" \
# -w "$TOPDIR" \
# -e DISPLAY \
# -h ${NAME} --name ${NAME} \
# ${IMAGE} "$@"
exec docker run --rm \
-it --privileged \
-u "$UID_GID" \
-v /dev/dri:/dev/dri \
-v "$HOME":"$HOME" \
-v env_setup.sh:/env_setup.sh \
-h ${NAME} --name ${NAME} \
${IMAGE} "$@"