From c0d186e83e985206cd3f87d1b5a60bd5a2f5f566 Mon Sep 17 00:00:00 2001 From: hrjp Date: Wed, 6 Mar 2024 22:31:24 +0900 Subject: [PATCH] nethost cmd add --- README.md | 4 +- docker/naviton_melodic/run.bash | 11 ++- docker/ros2_foxy/Dockerfile | 2 +- docker/ros2_foxy/run.bash | 11 ++- docker/ros2_galactic/Dockerfile | 2 +- docker/ros2_galactic/run.bash | 11 ++- docker/ros2_galactic/run_without_nethost.bash | 74 ------------------ docker/ros2_humble/run.bash | 8 +- docker/ros2_humble/run_without_nethost.bash | 74 ------------------ docker/ros_melodic/run.bash | 11 ++- docker/ros_noetic/run.bash | 12 +-- docker/slam_melodic/run.bash | 11 ++- docker/ubuntu18_cudagl/run.bash | 11 ++- docker/ubuntu20_cudagl/run.bash | 11 ++- docker/yolov5/run.bash | 75 ------------------- docker/yolox_noetic/run.bash | 11 ++- 16 files changed, 72 insertions(+), 267 deletions(-) delete mode 100755 docker/ros2_galactic/run_without_nethost.bash delete mode 100755 docker/ros2_humble/run_without_nethost.bash delete mode 100755 docker/yolov5/run.bash diff --git a/README.md b/README.md index 0c212e9..29bfa3f 100644 --- a/README.md +++ b/README.md @@ -56,9 +56,6 @@ git clone https://github.com/hrjp/rosenv # Ubuntu 20.04 ./rosenv/docker/ubuntu20/run.bash -# YOLO v5 -./rosenv/docker/yolo5/run.bash - # YOLOX with ROS1 noetic ./rosenv/docker/ubuntu20/run.bash @@ -73,6 +70,7 @@ git clone https://github.com/hrjp/rosenv | :--- | :--- | :--- | | -g | | GPUを使用する | | -r | | コンテナからexitした際にコンテナを自動消去する | +| -w | | --net-host をつけないで実行する(コンテナ外とネットワークを分離する) | | -n CONTAINER_NAME | | コンテナの名前 | | -s SHARE_FOLDER_PATH | | コンテナ内部と共有するディレクトリのパス
rosbagをやデータを外部と共有する際に使用
(ex. shareフォルダを作ってから /home/$USER/share ) | diff --git a/docker/naviton_melodic/run.bash b/docker/naviton_melodic/run.bash index 149d403..90d73dc 100755 --- a/docker/naviton_melodic/run.bash +++ b/docker/naviton_melodic/run.bash @@ -6,6 +6,7 @@ SHARE_FOLDER_PATH="" SHARE_FOLDER_CMD="" GPU_CMD="" CONTAINER_NAME_CMD="--name $CONTAINER_NAME" +NETHOST_CMD="--net=host" usage_exit() { echo " " 1>&2 @@ -20,7 +21,7 @@ usage_exit() { exit 1 } -while getopts grn:s:h OPT +while getopts grwn:s:h OPT do case $OPT in g ) GPU_CMD="--gpus all" @@ -30,6 +31,9 @@ do CONTAINER_NAME_CMD="" echo " Remove when exit this container" 1>&2 ;; + w ) NETHOST_CMD="" + echo " Not using --net=host" 1>&2 + ;; n) CONTAINER_NAME=$OPTARG CONTAINER_NAME_CMD="--name $CONTAINER_NAME" echo " CONTAINER_NAME = $OPTARG " 1>&2 @@ -69,7 +73,6 @@ docker run -it $CONTAINER_NAME_CMD\ -e QT_X11_NO_MITSHM=1 \ $GPU_CMD \ $REMOVE_CMD \ - --net=host \ + $NETHOST_CMD \ --privileged \ - $IMAGE_NAME /bin/bash - + $IMAGE_NAME /bin/bash \ No newline at end of file diff --git a/docker/ros2_foxy/Dockerfile b/docker/ros2_foxy/Dockerfile index 0769b74..bcd02b2 100644 --- a/docker/ros2_foxy/Dockerfile +++ b/docker/ros2_foxy/Dockerfile @@ -42,7 +42,7 @@ ARG ros2_ver=foxy ENV ROS_DISTRO=$ros2_ver #Indtall ROS2(Foxy etc..) and Install Tool for ROS2 and setup script の自動実行 and Install turtlesim and gazebo and Install ros2_example and turtulebot3_gazebo(waffle or burger) -RUN apt install -y ros-$ROS_DISTRO-desktop ros-$ROS_DISTRO-turtlesim ros-$ROS_DISTRO-gazebo-ros-pkgs \ +RUN apt install -y ros-$ROS_DISTRO-desktop-full ros-$ROS_DISTRO-turtlesim ros-$ROS_DISTRO-gazebo-ros-pkgs \ python3-rosdep python3-argcomplete python3-colcon-common-extensions && \ echo "ros installed" && \ rosdep init && \ diff --git a/docker/ros2_foxy/run.bash b/docker/ros2_foxy/run.bash index 9f19e31..55834bb 100755 --- a/docker/ros2_foxy/run.bash +++ b/docker/ros2_foxy/run.bash @@ -6,6 +6,7 @@ SHARE_FOLDER_PATH="" SHARE_FOLDER_CMD="" GPU_CMD="" CONTAINER_NAME_CMD="--name $CONTAINER_NAME" +NETHOST_CMD="--net=host" usage_exit() { echo " " 1>&2 @@ -20,7 +21,7 @@ usage_exit() { exit 1 } -while getopts grn:s:h OPT +while getopts grwn:s:h OPT do case $OPT in g ) GPU_CMD="--gpus all" @@ -30,6 +31,9 @@ do CONTAINER_NAME_CMD="" echo " Remove when exit this container" 1>&2 ;; + w ) NETHOST_CMD="" + echo " Not using --net=host" 1>&2 + ;; n) CONTAINER_NAME=$OPTARG CONTAINER_NAME_CMD="--name $CONTAINER_NAME" echo " CONTAINER_NAME = $OPTARG " 1>&2 @@ -69,7 +73,6 @@ docker run -it $CONTAINER_NAME_CMD\ -e QT_X11_NO_MITSHM=1 \ $GPU_CMD \ $REMOVE_CMD \ - --net=host \ + $NETHOST_CMD \ --privileged \ - $IMAGE_NAME /bin/bash - + $IMAGE_NAME /bin/bash \ No newline at end of file diff --git a/docker/ros2_galactic/Dockerfile b/docker/ros2_galactic/Dockerfile index eb885b2..4a35371 100644 --- a/docker/ros2_galactic/Dockerfile +++ b/docker/ros2_galactic/Dockerfile @@ -36,7 +36,7 @@ ARG ros2_ver=galactic ENV ROS_DISTRO=$ros2_ver #Indtall ROS2(Foxy etc..) and Install Tool for ROS2 and setup script の自動実行 and Install turtlesim and gazebo and Install ros2_example and turtulebot3_gazebo(waffle or burger) -RUN apt install -y ros-$ROS_DISTRO-desktop ros-$ROS_DISTRO-turtlesim ros-$ROS_DISTRO-gazebo-ros-pkgs \ +RUN apt install -y ros-$ROS_DISTRO-desktop-full ros-$ROS_DISTRO-turtlesim ros-$ROS_DISTRO-gazebo-ros-pkgs \ python3-rosdep python3-argcomplete python3-colcon-common-extensions && \ apt install -y python3-vcstool && \ echo "ros installed" && \ diff --git a/docker/ros2_galactic/run.bash b/docker/ros2_galactic/run.bash index 711dc97..aaf4c66 100755 --- a/docker/ros2_galactic/run.bash +++ b/docker/ros2_galactic/run.bash @@ -6,6 +6,7 @@ SHARE_FOLDER_PATH="" SHARE_FOLDER_CMD="" GPU_CMD="" CONTAINER_NAME_CMD="--name $CONTAINER_NAME" +NETHOST_CMD="--net=host" usage_exit() { echo " " 1>&2 @@ -20,7 +21,7 @@ usage_exit() { exit 1 } -while getopts grn:s:h OPT +while getopts grwn:s:h OPT do case $OPT in g ) GPU_CMD="--gpus all" @@ -30,6 +31,9 @@ do CONTAINER_NAME_CMD="" echo " Remove when exit this container" 1>&2 ;; + w ) NETHOST_CMD="" + echo " Not using --net=host" 1>&2 + ;; n) CONTAINER_NAME=$OPTARG CONTAINER_NAME_CMD="--name $CONTAINER_NAME" echo " CONTAINER_NAME = $OPTARG " 1>&2 @@ -69,7 +73,6 @@ docker run -it $CONTAINER_NAME_CMD\ -e QT_X11_NO_MITSHM=1 \ $GPU_CMD \ $REMOVE_CMD \ - --net=host \ + $NETHOST_CMD \ --privileged \ - $IMAGE_NAME /bin/bash - + $IMAGE_NAME /bin/bash \ No newline at end of file diff --git a/docker/ros2_galactic/run_without_nethost.bash b/docker/ros2_galactic/run_without_nethost.bash deleted file mode 100755 index 2cc15bb..0000000 --- a/docker/ros2_galactic/run_without_nethost.bash +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/bash - -IMAGE_NAME=hrjp/ros2:galactic_cudagl -CONTAINER_NAME=ros2_galactic -SHARE_FOLDER_PATH="" -SHARE_FOLDER_CMD="" -GPU_CMD="" -CONTAINER_NAME_CMD="--name $CONTAINER_NAME" - -usage_exit() { - echo " " 1>&2 - echo " -----------------------------------------------------------------------------" 1>&2 - echo " OPTIONS | DETAILS " 1>&2 - echo " -----------------------------------------------------------------------------" 1>&2 - echo " -g | GPU enabled" 1>&2 - echo " -r | remove when exit the container" 1>&2 - echo " -n CONTAINER_NAME | container name (default : $CONTAINER_NAME )" 1>&2 - echo " -s SHARE_FOLDER_PATH | directory path shared with the inside of the container" 1>&2 - echo " -----------------------------------------------------------------------------" 1>&2 - exit 1 -} - -while getopts grn:s:h OPT -do - case $OPT in - g ) GPU_CMD="--gpus all" - echo " Using nvidia GPUs" 1>&2 - ;; - r ) REMOVE_CMD="--rm" - CONTAINER_NAME_CMD="" - echo " Remove when exit this container" 1>&2 - ;; - n) CONTAINER_NAME=$OPTARG - CONTAINER_NAME_CMD="--name $CONTAINER_NAME" - echo " CONTAINER_NAME = $OPTARG " 1>&2 - ;; - s ) SHARE_FOLDER_PATH=$OPTARG - SHARE_FOLDER_CMD="-v $SHARE_FOLDER_PATH:/home/share" - echo " SHARE_FOLDER_PATH = $SHARE_FOLDER_PATH " 1>&2 - ;; - h ) usage_exit - ;; - \? ) usage_exit - ;; - esac -done - - - -if [ -z $REMOVE_CMD ]; then - cd - if [ ! -f $CONTAINER_NAME.bash ]; then - touch $CONTAINER_NAME.bash - sudo chmod 777 $CONTAINER_NAME.bash - echo -e "xhost + \n docker start $CONTAINER_NAME \n docker exec -it $CONTAINER_NAME /bin/bash" >>$CONTAINER_NAME.bash - fi -else - CONTAINER_NAME="" -fi - -xhost + - -docker run -it $CONTAINER_NAME_CMD\ - -v /dev:/dev \ - -v /tmp/.X11-unix:/tmp/.X11-unix \ - -v $HOME/.Xauthority:/root/.Xauthority:rw \ - $SHARE_FOLDER_CMD \ - -e DISPLAY=$DISPLAY \ - -e QT_X11_NO_MITSHM=1 \ - $GPU_CMD \ - $REMOVE_CMD \ - --privileged \ - $IMAGE_NAME /bin/bash - diff --git a/docker/ros2_humble/run.bash b/docker/ros2_humble/run.bash index c449a1b..58c8258 100755 --- a/docker/ros2_humble/run.bash +++ b/docker/ros2_humble/run.bash @@ -6,6 +6,7 @@ SHARE_FOLDER_PATH="" SHARE_FOLDER_CMD="" GPU_CMD="" CONTAINER_NAME_CMD="--name $CONTAINER_NAME" +NETHOST_CMD="--net=host" usage_exit() { echo " " 1>&2 @@ -20,7 +21,7 @@ usage_exit() { exit 1 } -while getopts grn:s:h OPT +while getopts grwn:s:h OPT do case $OPT in g ) GPU_CMD="--gpus all" @@ -30,6 +31,9 @@ do CONTAINER_NAME_CMD="" echo " Remove when exit this container" 1>&2 ;; + w ) NETHOST_CMD="" + echo " Not using --net=host" 1>&2 + ;; n) CONTAINER_NAME=$OPTARG CONTAINER_NAME_CMD="--name $CONTAINER_NAME" echo " CONTAINER_NAME = $OPTARG " 1>&2 @@ -69,7 +73,7 @@ docker run -it $CONTAINER_NAME_CMD\ -e QT_X11_NO_MITSHM=1 \ $GPU_CMD \ $REMOVE_CMD \ - --net=host \ + $NETHOST_CMD \ --privileged \ $IMAGE_NAME /bin/bash diff --git a/docker/ros2_humble/run_without_nethost.bash b/docker/ros2_humble/run_without_nethost.bash deleted file mode 100755 index b30639f..0000000 --- a/docker/ros2_humble/run_without_nethost.bash +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/bash - -IMAGE_NAME=hrjp/ros2:humble_cuda -CONTAINER_NAME=ros2_humble -SHARE_FOLDER_PATH="" -SHARE_FOLDER_CMD="" -GPU_CMD="" -CONTAINER_NAME_CMD="--name $CONTAINER_NAME" - -usage_exit() { - echo " " 1>&2 - echo " -----------------------------------------------------------------------------" 1>&2 - echo " OPTIONS | DETAILS " 1>&2 - echo " -----------------------------------------------------------------------------" 1>&2 - echo " -g | GPU enabled" 1>&2 - echo " -r | remove when exit the container" 1>&2 - echo " -n CONTAINER_NAME | container name (default : $CONTAINER_NAME )" 1>&2 - echo " -s SHARE_FOLDER_PATH | directory path shared with the inside of the container" 1>&2 - echo " -----------------------------------------------------------------------------" 1>&2 - exit 1 -} - -while getopts grn:s:h OPT -do - case $OPT in - g ) GPU_CMD="--gpus all" - echo " Using nvidia GPUs" 1>&2 - ;; - r ) REMOVE_CMD="--rm" - CONTAINER_NAME_CMD="" - echo " Remove when exit this container" 1>&2 - ;; - n) CONTAINER_NAME=$OPTARG - CONTAINER_NAME_CMD="--name $CONTAINER_NAME" - echo " CONTAINER_NAME = $OPTARG " 1>&2 - ;; - s ) SHARE_FOLDER_PATH=$OPTARG - SHARE_FOLDER_CMD="-v $SHARE_FOLDER_PATH:/home/share" - echo " SHARE_FOLDER_PATH = $SHARE_FOLDER_PATH " 1>&2 - ;; - h ) usage_exit - ;; - \? ) usage_exit - ;; - esac -done - - - -if [ -z $REMOVE_CMD ]; then - cd - if [ ! -f $CONTAINER_NAME.bash ]; then - touch $CONTAINER_NAME.bash - sudo chmod 777 $CONTAINER_NAME.bash - echo -e "xhost + \n docker start $CONTAINER_NAME \n docker exec -it $CONTAINER_NAME /bin/bash" >>$CONTAINER_NAME.bash - fi -else - CONTAINER_NAME="" -fi - -xhost + - -docker run -it $CONTAINER_NAME_CMD\ - -v /dev:/dev \ - -v /tmp/.X11-unix:/tmp/.X11-unix \ - -v $HOME/.Xauthority:/root/.Xauthority:rw \ - $SHARE_FOLDER_CMD \ - -e DISPLAY=$DISPLAY \ - -e QT_X11_NO_MITSHM=1 \ - $GPU_CMD \ - $REMOVE_CMD \ - --privileged \ - $IMAGE_NAME /bin/bash - diff --git a/docker/ros_melodic/run.bash b/docker/ros_melodic/run.bash index 446e6ec..8116be7 100755 --- a/docker/ros_melodic/run.bash +++ b/docker/ros_melodic/run.bash @@ -6,6 +6,7 @@ SHARE_FOLDER_PATH="" SHARE_FOLDER_CMD="" GPU_CMD="" CONTAINER_NAME_CMD="--name $CONTAINER_NAME" +NETHOST_CMD="--net=host" usage_exit() { echo " " 1>&2 @@ -20,7 +21,7 @@ usage_exit() { exit 1 } -while getopts grn:s:h OPT +while getopts grwn:s:h OPT do case $OPT in g ) GPU_CMD="--gpus all" @@ -30,6 +31,9 @@ do CONTAINER_NAME_CMD="" echo " Remove when exit this container" 1>&2 ;; + w ) NETHOST_CMD="" + echo " Not using --net=host" 1>&2 + ;; n) CONTAINER_NAME=$OPTARG CONTAINER_NAME_CMD="--name $CONTAINER_NAME" echo " CONTAINER_NAME = $OPTARG " 1>&2 @@ -69,7 +73,6 @@ docker run -it $CONTAINER_NAME_CMD\ -e QT_X11_NO_MITSHM=1 \ $GPU_CMD \ $REMOVE_CMD \ - --net=host \ + $NETHOST_CMD \ --privileged \ - $IMAGE_NAME /bin/bash - + $IMAGE_NAME /bin/bash \ No newline at end of file diff --git a/docker/ros_noetic/run.bash b/docker/ros_noetic/run.bash index 80fe294..5511a2b 100755 --- a/docker/ros_noetic/run.bash +++ b/docker/ros_noetic/run.bash @@ -1,12 +1,12 @@ #!/bin/bash - IMAGE_NAME=hrjp/ros:noetic_cudagl CONTAINER_NAME=ros_noetic SHARE_FOLDER_PATH="" SHARE_FOLDER_CMD="" GPU_CMD="" CONTAINER_NAME_CMD="--name $CONTAINER_NAME" +NETHOST_CMD="--net=host" usage_exit() { echo " " 1>&2 @@ -21,7 +21,7 @@ usage_exit() { exit 1 } -while getopts grn:s:h OPT +while getopts grwn:s:h OPT do case $OPT in g ) GPU_CMD="--gpus all" @@ -31,6 +31,9 @@ do CONTAINER_NAME_CMD="" echo " Remove when exit this container" 1>&2 ;; + w ) NETHOST_CMD="" + echo " Not using --net=host" 1>&2 + ;; n) CONTAINER_NAME=$OPTARG CONTAINER_NAME_CMD="--name $CONTAINER_NAME" echo " CONTAINER_NAME = $OPTARG " 1>&2 @@ -70,7 +73,6 @@ docker run -it $CONTAINER_NAME_CMD\ -e QT_X11_NO_MITSHM=1 \ $GPU_CMD \ $REMOVE_CMD \ - --net=host \ + $NETHOST_CMD \ --privileged \ - $IMAGE_NAME /bin/bash - + $IMAGE_NAME /bin/bash \ No newline at end of file diff --git a/docker/slam_melodic/run.bash b/docker/slam_melodic/run.bash index c9eaf2b..fbba135 100755 --- a/docker/slam_melodic/run.bash +++ b/docker/slam_melodic/run.bash @@ -6,6 +6,7 @@ SHARE_FOLDER_PATH="" SHARE_FOLDER_CMD="" GPU_CMD="" CONTAINER_NAME_CMD="--name $CONTAINER_NAME" +NETHOST_CMD="--net=host" usage_exit() { echo " " 1>&2 @@ -20,7 +21,7 @@ usage_exit() { exit 1 } -while getopts grn:s:h OPT +while getopts grwn:s:h OPT do case $OPT in g ) GPU_CMD="--gpus all" @@ -30,6 +31,9 @@ do CONTAINER_NAME_CMD="" echo " Remove when exit this container" 1>&2 ;; + w ) NETHOST_CMD="" + echo " Not using --net=host" 1>&2 + ;; n) CONTAINER_NAME=$OPTARG CONTAINER_NAME_CMD="--name $CONTAINER_NAME" echo " CONTAINER_NAME = $OPTARG " 1>&2 @@ -69,7 +73,6 @@ docker run -it $CONTAINER_NAME_CMD\ -e QT_X11_NO_MITSHM=1 \ $GPU_CMD \ $REMOVE_CMD \ - --net=host \ + $NETHOST_CMD \ --privileged \ - $IMAGE_NAME /bin/bash - + $IMAGE_NAME /bin/bash \ No newline at end of file diff --git a/docker/ubuntu18_cudagl/run.bash b/docker/ubuntu18_cudagl/run.bash index 7295410..61db73d 100755 --- a/docker/ubuntu18_cudagl/run.bash +++ b/docker/ubuntu18_cudagl/run.bash @@ -6,6 +6,7 @@ SHARE_FOLDER_PATH="" SHARE_FOLDER_CMD="" GPU_CMD="" CONTAINER_NAME_CMD="--name $CONTAINER_NAME" +NETHOST_CMD="--net=host" usage_exit() { echo " " 1>&2 @@ -20,7 +21,7 @@ usage_exit() { exit 1 } -while getopts grn:s:h OPT +while getopts grwn:s:h OPT do case $OPT in g ) GPU_CMD="--gpus all" @@ -30,6 +31,9 @@ do CONTAINER_NAME_CMD="" echo " Remove when exit this container" 1>&2 ;; + w ) NETHOST_CMD="" + echo " Not using --net=host" 1>&2 + ;; n) CONTAINER_NAME=$OPTARG CONTAINER_NAME_CMD="--name $CONTAINER_NAME" echo " CONTAINER_NAME = $OPTARG " 1>&2 @@ -69,7 +73,6 @@ docker run -it $CONTAINER_NAME_CMD\ -e QT_X11_NO_MITSHM=1 \ $GPU_CMD \ $REMOVE_CMD \ - --net=host \ + $NETHOST_CMD \ --privileged \ - $IMAGE_NAME /bin/bash - + $IMAGE_NAME /bin/bash \ No newline at end of file diff --git a/docker/ubuntu20_cudagl/run.bash b/docker/ubuntu20_cudagl/run.bash index ab1298c..b59e362 100755 --- a/docker/ubuntu20_cudagl/run.bash +++ b/docker/ubuntu20_cudagl/run.bash @@ -6,6 +6,7 @@ SHARE_FOLDER_PATH="" SHARE_FOLDER_CMD="" GPU_CMD="" CONTAINER_NAME_CMD="--name $CONTAINER_NAME" +NETHOST_CMD="--net=host" usage_exit() { echo " " 1>&2 @@ -20,7 +21,7 @@ usage_exit() { exit 1 } -while getopts grn:s:h OPT +while getopts grwn:s:h OPT do case $OPT in g ) GPU_CMD="--gpus all" @@ -30,6 +31,9 @@ do CONTAINER_NAME_CMD="" echo " Remove when exit this container" 1>&2 ;; + w ) NETHOST_CMD="" + echo " Not using --net=host" 1>&2 + ;; n) CONTAINER_NAME=$OPTARG CONTAINER_NAME_CMD="--name $CONTAINER_NAME" echo " CONTAINER_NAME = $OPTARG " 1>&2 @@ -69,7 +73,6 @@ docker run -it $CONTAINER_NAME_CMD\ -e QT_X11_NO_MITSHM=1 \ $GPU_CMD \ $REMOVE_CMD \ - --net=host \ + $NETHOST_CMD \ --privileged \ - $IMAGE_NAME /bin/bash - + $IMAGE_NAME /bin/bash \ No newline at end of file diff --git a/docker/yolov5/run.bash b/docker/yolov5/run.bash deleted file mode 100755 index 4d0cd45..0000000 --- a/docker/yolov5/run.bash +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/bash - -IMAGE_NAME=hrjp/yolov5:naviton -CONTAINER_NAME=yolov5_naviton -SHARE_FOLDER_PATH="" -SHARE_FOLDER_CMD="" -GPU_CMD="" -CONTAINER_NAME_CMD="--name $CONTAINER_NAME" - -usage_exit() { - echo " " 1>&2 - echo " -----------------------------------------------------------------------------" 1>&2 - echo " OPTIONS | DETAILS " 1>&2 - echo " -----------------------------------------------------------------------------" 1>&2 - echo " -g | GPU enabled" 1>&2 - echo " -r | remove when exit the container" 1>&2 - echo " -n CONTAINER_NAME | container name (default : $CONTAINER_NAME )" 1>&2 - echo " -s SHARE_FOLDER_PATH | directory path shared with the inside of the container" 1>&2 - echo " -----------------------------------------------------------------------------" 1>&2 - exit 1 -} - -while getopts grn:s:h OPT -do - case $OPT in - g ) GPU_CMD="--gpus all" - echo " Using nvidia GPUs" 1>&2 - ;; - r ) REMOVE_CMD="--rm" - CONTAINER_NAME_CMD="" - echo " Remove when exit this container" 1>&2 - ;; - n) CONTAINER_NAME=$OPTARG - CONTAINER_NAME_CMD="--name $CONTAINER_NAME" - echo " CONTAINER_NAME = $OPTARG " 1>&2 - ;; - s ) SHARE_FOLDER_PATH=$OPTARG - SHARE_FOLDER_CMD="-v $SHARE_FOLDER_PATH:/home/share" - echo " SHARE_FOLDER_PATH = $SHARE_FOLDER_PATH " 1>&2 - ;; - h ) usage_exit - ;; - \? ) usage_exit - ;; - esac -done - - - -if [ -z $REMOVE_CMD ]; then - cd - if [ ! -f $CONTAINER_NAME.bash ]; then - touch $CONTAINER_NAME.bash - sudo chmod 777 $CONTAINER_NAME.bash - echo -e "xhost + \n docker start $CONTAINER_NAME \n docker exec -it $CONTAINER_NAME /bin/bash" >>$CONTAINER_NAME.bash - fi -else - CONTAINER_NAME="" -fi - -xhost + - -docker run -it $CONTAINER_NAME_CMD\ - -v /dev:/dev \ - -v /tmp/.X11-unix:/tmp/.X11-unix \ - -v $HOME/.Xauthority:/root/.Xauthority:rw \ - $SHARE_FOLDER_CMD \ - -e DISPLAY=$DISPLAY \ - -e QT_X11_NO_MITSHM=1 \ - $GPU_CMD \ - $REMOVE_CMD \ - --net=host \ - --privileged \ - $IMAGE_NAME /bin/bash - diff --git a/docker/yolox_noetic/run.bash b/docker/yolox_noetic/run.bash index 44e3021..5b15115 100755 --- a/docker/yolox_noetic/run.bash +++ b/docker/yolox_noetic/run.bash @@ -6,6 +6,7 @@ SHARE_FOLDER_PATH="" SHARE_FOLDER_CMD="" GPU_CMD="" CONTAINER_NAME_CMD="--name $CONTAINER_NAME" +NETHOST_CMD="--net=host" usage_exit() { echo " " 1>&2 @@ -20,7 +21,7 @@ usage_exit() { exit 1 } -while getopts grn:s:h OPT +while getopts grwn:s:h OPT do case $OPT in g ) GPU_CMD="--gpus all" @@ -30,6 +31,9 @@ do CONTAINER_NAME_CMD="" echo " Remove when exit this container" 1>&2 ;; + w ) NETHOST_CMD="" + echo " Not using --net=host" 1>&2 + ;; n) CONTAINER_NAME=$OPTARG CONTAINER_NAME_CMD="--name $CONTAINER_NAME" echo " CONTAINER_NAME = $OPTARG " 1>&2 @@ -69,7 +73,6 @@ docker run -it $CONTAINER_NAME_CMD\ -e QT_X11_NO_MITSHM=1 \ $GPU_CMD \ $REMOVE_CMD \ - --net=host \ + $NETHOST_CMD \ --privileged \ - $IMAGE_NAME /bin/bash - + $IMAGE_NAME /bin/bash \ No newline at end of file