-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun
executable file
·37 lines (34 loc) · 1.38 KB
/
run
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
#!/bin/bash
if [ "$#" -ne 1 ]; then
IMAGE_TYPE=docker
else
IMAGE_TYPE=$1
fi
IMAGE_NAME="robotica:$IMAGE_TYPE"
CONTAINER_NAME="robotica_$IMAGE_TYPE"
if [ ! $(docker ps --quiet --filter name=$CONTAINER_NAME) ]; then
xhost +local:docker
echo "Running container"
docker run -it --rm \
--privileged \
--network host \
--env DISPLAY \
--volume $HOME/.bash_history:/home/robotica/.bash_history:rw \
--volume $HOME/.Xauthority:/home/robotica/.Xauthority:rw \
--volume /tmp/.X11-unix:/tmp/.X11-unix:rw \
--user $(id -u $USER):$(id -g $USER) \
--volume $HOME/catkin_ws/src/$IMAGE_TYPE:/home/robotica/catkin_ws/src:rw \
--volume $HOME/catkin_ws/.$IMAGE_TYPE/build:/home/robotica/catkin_ws/build:rw \
--volume $HOME/catkin_ws/.$IMAGE_TYPE/devel:/home/robotica/catkin_ws/devel:rw \
--volume $HOME/colcon_ws/src/$IMAGE_TYPE:/home/robotica/colcon_ws/src:rw \
--volume $HOME/colcon_ws/.$IMAGE_TYPE/build:/home/robotica/colcon_ws/build:rw \
--volume $HOME/colcon_ws/.$IMAGE_TYPE/install:/home/robotica/colcon_ws/install:rw \
--gpus all \
--workdir /home/robotica \
--name $CONTAINER_NAME \
$IMAGE_NAME bash
xhost -local:docker
else
echo "Container is already running, another terminal in the same container is opened"
docker exec -it $CONTAINER_NAME bash
fi