-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaunch_docker.sh
executable file
·57 lines (48 loc) · 1.5 KB
/
launch_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
#!/bin/bash
xhost +local:root
# container name
ctr_name="$1"
# image name
img_name="$2"
# abs path to the src folder desired in the volume
path_src="$3"
if [ "$#" != "3" ];
then
echo "<container_name> <image_name> <abs_path_to_src>"
exit 1
fi
# checking container already ready
if docker container ls -a | grep -q $ctr_name; then
echo "Container called already present!"
if !(docker container ls | grep -q $ctr_name); then # is container started?
docker start $ctr_name
fi
docker exec -it $ctr_name bash
fi
echo "----------------------------"
echo "running container: $ctr_name"
echo "generated from image: $img_name "
echo "volume folder: $path_src"
echo "-----------------------------"
docker run --gpus all -it \
--runtime=nvidia \
--network=host \
--env="DISPLAY" \
--env="QT_X11_NO_MITSHM=1" \
--volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
--workdir="/home/$USER" \
--volume="$path_src:/home/$USER/catkin_ws/src" \
--volume="/etc/group:/etc/group:ro" \
--volume="/etc/passwd:/etc/passwd:ro" \
--volume="/etc/shadow:/etc/shadow:ro" \
--volume="/etc/sudoers.d:/etc/sudoers.d:ro" \
--volume="$HOME/host_docker:/home/user/host_docker" \
-e LOCAL_USER_ID=`id -u $USER` \
-e LOCAL_GROUP_ID=`id -g $USER` \
-e LOCAL_GROUP_NAME=`id -gn $USER` \
--device /dev/snd \
-e PULSE_SERVER=unix:${XDG_RUNTIME_DIR}/pulse/native \
-v ${XDG_RUNTIME_DIR}/pulse/native:${XDG_RUNTIME_DIR}/pulse/native \
--group-add $(getent group audio | cut -d: -f3) \
--name=$ctr_name $img_name
xhost -local:root