From 4a27bd8efcbe8999f587ae9f3f81506537715813 Mon Sep 17 00:00:00 2001 From: Tae Young Kim Date: Thu, 27 Jul 2023 10:40:57 +0900 Subject: [PATCH] Add docker container script --- docker/container_run.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 docker/container_run.sh diff --git a/docker/container_run.sh b/docker/container_run.sh new file mode 100755 index 00000000..c09bb583 --- /dev/null +++ b/docker/container_run.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# Author : Taeyoung Kim (https://github.com/Taeyoung96) + +# Set the project directory (PROJECT_DIR) as the parent directory of the current working directory +PROJECT_DIR=$(dirname "$PWD") + +# Move to the parent folder of the project directory +cd "$PROJECT_DIR" + +# Print the current working directory to verify the change +echo "Current working directory: $PROJECT_DIR" + +# Check if arguments are provided for the image name and tag +if [ "$#" -ne 2 ]; then + echo "Usage: $0 " + exit 1 +fi + +# Assign the arguments to variables for clarity +CONTAINER_NAME="$1" +IMAGE_NAME="$2" + +# Launch the nvidia-docker container with the provided image name and tag +nvidia-docker run --privileged -it \ + -e NVIDIA_DRIVER_CAPABILITIES=all \ + -e NVIDIA_VISIBLE_DEVICES=all \ + --volume="$PROJECT_DIR:/root/ros2_ws/src" \ + --volume=/data/LIDAR_dataset:/root/data \ + --volume=/tmp/.X11-unix:/tmp/.X11-unix:rw \ + --net=host \ + --ipc=host \ + --shm-size=4gb \ + --name="$CONTAINER_NAME" \ + --env="DISPLAY=$DISPLAY" \ + "$IMAGE_NAME" /bin/bash \ No newline at end of file