-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_docker.sh
81 lines (66 loc) · 2.16 KB
/
run_docker.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
uname -m
set -x
xhost +
login=$(aws ecr get-login --no-include-email)
$login
docker image prune -f
docker_name="trt_profile"
aws_creds="${HOME}/.aws/credentials"
aws_env=""
webcam_str=""
echo "Home"
echo "${HOME}"
#docker rmi -f ${docker_name}
# if [ -f $aws_creds ]
# then
# aws_id="$(cat $aws_creds | grep id | cut -f2 -d= | sed 's# ##g')"
# aws_secret="$(cat $aws_creds | grep secret | cut -f2 -d= | sed 's# ##g')"
# aws_env="-e AWS_ACCESS_KEY_ID=${aws_id} -e AWS_SECRET_ACCESS_KEY=${aws_secret}"
# else
# echo "Please run `aws configure`, ~/.aws/credentials are required for this to run"
# exit 1
# fi
port_forward="-p 8022:22"
hostname_prefix=$(hostname | cut -f1 -d-)
if [ $hostname_prefix == "ip" ]
then
# if on an ec2 machine, do not forward anything, just let it run
echo "Detected an EC2 instance, no running display or webcam forwarding to containers"
display_str=""
webcam_str=""
else
# forward display into docker container
#display_str="--rm -ti --net=host --ipc=host -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --env=\"DISPLAY\""
display_str="--rm -ti --ipc=host -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --env=\"DISPLAY\""
# forward webcam into docker container
if [ -f /dev/video0 ]
then
webcam_str="--device=/dev/video0:/dev/video0"
fi
fi
# change flag to F
# docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
case $( uname -m ) in
x86*)
nvidia-docker build -t ${docker_name} -f Dockerfile .
;;
aar*)
nvidia-docker build -t ${docker_name} -f Dockerfile .
;;
*)
echo -n "unknown platform"
esac
container_name="--name trt_profile"
entrypoint="--entrypoint service ssh restart && /bin/bash"
case $( uname -m ) in
x86*)
#nvidia-docker run -it -v ${PWD}:/app ${port_forward} ${container_name} ${display_str} ${webcam_str} ${aws_env} ${docker_name} $*
nvidia-docker run -it -v ${PWD}:/app ${port_forward} ${container_name} ${display_str} ${webcam_str} ${aws_env} ${docker_name} ${entrypoint}
;;
aar*)
nvidia-docker run --entrypoint="" --privileged -v ${PWD}:/app ${display_str} ${webcam_str} ${aws_env} ${docker_name} $*
;;
*)
echo -n "unknown platform"
esac