-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjoin.bash
executable file
·44 lines (36 loc) · 943 Bytes
/
join.bash
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
#!/usr/bin/env bash
IMG="rolling-harmonic"
CONTAINER_ID=""
if docker info -f '{{ range $key, $value := .Runtimes }}{{ $key }}{{ end }}' | grep nvidia > /dev/null 2>&1; then
IMG="$IMG-nvidia"
fi
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-i)
IMG="$2"
shift 2
;;
--name)
CONTAINER_ID="$2"
shift 2
;;
*) # unknown option
echo "Unknown option" >&2
exit 1
;;
esac
done
if [ -z "$CONTAINER_ID" ]; then
CONTAINER_ID="$(docker ps -qf "ancestor=${IMG}")"
fi
num_containers="$(echo "$CONTAINER_ID" | wc -l)"
if [ "$num_containers" = "0" ]; then
echo "There are no running containers to join" >&2
exit 1
elif [ "$num_containers" -gt "1" ]; then
echo "There are multiple containers to join. You must specify one" >&2
exit 1
fi
docker exec --privileged -e DISPLAY -it "${CONTAINER_ID}" bash -c "cd /home/ioes-docker/host && exec bash"