From 1897e35763a83cf82cf1a9ec4f7d34da144708a8 Mon Sep 17 00:00:00 2001 From: csvke Date: Sat, 28 Sep 2024 02:11:15 +0800 Subject: [PATCH] Generate unique container names in run.sh --- run.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/run.sh b/run.sh index 5963d096e..d9af1645b 100755 --- a/run.sh +++ b/run.sh @@ -184,6 +184,12 @@ done # Track container ID for `docker wait` container_id="" +# Generate a unique container name +BUILD_DATE_TIME=$(date +%Y%m%d_%H%M%S) +CONTAINER_IMAGE_NAME=$(basename "${filtered_args[0]}") +SANITIZED_CONTAINER_IMAGE_NAME=$(echo "$CONTAINER_IMAGE_NAME" | sed 's/[^a-zA-Z0-9_.-]/_/g') +CONTAINER_NAME="my_jetson_container_${SANITIZED_CONTAINER_IMAGE_NAME}_${BUILD_DATE_TIME}" + # run the container ARCH=$(uname -i) @@ -208,7 +214,7 @@ if [ $ARCH = "aarch64" ]; then --device /dev/snd \ --device /dev/bus/usb \ $OPTIONAL_PERMISSION_ARGS $DATA_VOLUME $DISPLAY_DEVICE $V4L2_DEVICES $I2C_DEVICES $JTOP_SOCKET $EXTRA_FLAGS \ - --name my_jetson_container \ + --name "$CONTAINER_NAME" \ "${filtered_args[@]}" set +x @@ -224,7 +230,7 @@ elif [ $ARCH = "x86_64" ]; then --env NVIDIA_DRIVER_CAPABILITIES=all \ --volume $ROOT/data:/data \ $OPTIONAL_ARGS $DATA_VOLUME $DISPLAY_DEVICE $V4L2_DEVICES $I2C_DEVICES $JTOP_SOCKET $EXTRA_FLAGS \ - --name my_jetson_container \ + --name "$CONTAINER_NAME" \ "${filtered_args[@]}" set +x