forked from zeal-up/Simple-LIO-SAM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker_run.sh
executable file
·86 lines (73 loc) · 2.08 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
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
82
83
84
85
86
#!/bin/bash
declare script_dir=$(cd $(dirname $0); pwd -P)
declare ARGS=$(getopt -o h,c:d: --long help,code:,data: -n "$0" -- "$@")
# echo ARGS=[$ARGS]
eval set -- "${ARGS}"
# echo formatted parameters=[$@]
declare docker_image_tag="v1.0"
declare docker_image_name="zeallin/spl_lio_sam"
declare docker_image="${docker_image_name}:${docker_image_tag}"
declare container_name="spl_lio_sam"
declare code_dir=""
declare data_dir=""
function Help() {
cat << EOF
docker_run.sh -- help script to run docker
Usage:
docker_run.sh [-h|--help] [-c|--code]
-h|--help Show help message
-c|--code Code directory mount into container
-d|--data Data directory mount into container
EOF
}
if [[ $1 ]]; then
while true;
do
case $1 in
-h|--help):
Help; exit 0; ;;
-c|--code):
code_dir=$2; shift 2; ;;
-d|--data):
data_dir=$2; shift 2; ;;
--)
shift; break; ;;
*)
echo "unrecognized arguments ${@}"
Help
exit 1
;;
esac
done
fi
if [[ $(docker ps -a | grep ${container_name}) ]]; then
echo "The container '${container_name}' is already runable, start or exec it"
exit 1
fi
if [[ $(docker images | grep ${docker_image_name} | grep ${docker_image_tag}) ]]; then
echo "The image has already exists, no need to pull"
else
docker pull ${docker_image}
fi
declare volumes=""
if [[ ${code_dir} ]]; then
volumes="-v ${code_dir}:/home/splsam/codes"
fi
if [[ ${data_dir} ]]; then
volumes="${volumes} -v ${data_dir}:/home/splsam/data"
fi
docker run -it \
-u $(id -u):$(id -g) \
--network=host \
-e HOME=/home/splsam \
${volumes} \
--name=${container_name} \
-e "QT_X11_NO_MITSHM=1" \
-e DISPLAY=unix$DISPLAY \
--workdir=/home/splsam \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp/.X11-unix:/tmp/.X11-unix \
--env="DISPLAY" \
--privileged \
-d ${docker_image}
${script_dir}/docker_into.sh ${container_name}