Docker Launch file no longer works

While learning docker I was given a start.sh script to run to start up and use docker locally, in getting more accustomed to docker I was ready to start making my own nodes on top of the repo already present, I was told to volume mount from the start script to be able to use my own files and when I tried to edit the script I somehow have broken it . before when I could enter and use the repo from running ./start.sh name image:tag

now I simply get an error stating “docker run” requires at least 1 argument." attached is the bash files code, any help would be greatly appreciated as I need to have docker working again hopefully soon !

DOCKER_CONTAINER_NAME=$1
DOCKER_IMAGE_NAME=$2


set -e;

xhost +local:root &

XSOCK=/tmp/.X11-unix
XAUTH=/tmp/.docker.xauth
WDIR=/home/caterpillar/ws




if [ -z $XAUTH ]; then
echo "[INFO] Removing $XAUTH"
rm -r $XAUTH;
fi

touch $XAUTH;
xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | sudo xauth -f $XAUTH nmerge -;

docker run -it --rm \
--name $DOCKER_CONTAINER_NAME \
--volume=$XSOCK:$XSOCK:rw \
--volume=$XAUTH:$XAUTH:rw \
--env="DISPLAY=$DISPLAY" \
--env="QT_X11_NO_MITSHM=1" \
--env="XAUTHORITY=$XAUTH" \
--env="GAZEBO_MODEL_DATABASE_URI=" \
--device=/dev/dri \
--gpus all \

$DOCKER_IMAGE_NAME

export containerId=$(docker ps -l -q)
xhost -local:root &

echo "Exit Docker run!"

Removing this blank line may help. The \ makes the next (now blank) line be part of the docker run command, but the line $DOCKER_IMAGE_NAME is not concatenated to that.

That worked ! Thank you ! And to volume mount a folder where would I add

-v $PWD localDirectory:dockerFolder: rw

and is that the correct command / code ?

To map a local folder, you’d need a bind mount, not a volume: Use bind mounts | Docker Documentation.

That said, it would just be an extra line like, for example, the --env ... \ lines. As you already have some --volume lines (which is the long name for -v), I’d add it around these lines, but that’s a matter of taste.

So, to mount some subfolder of your home directory into the container:

docker run -it --rm \
... \
--volume=$XSOCK:$XSOCK:rw \
--volume=$XAUTH:$XAUTH:rw \
--volume="$PWD/some/local/sub/folder":/some/folder/in/the/container:rw \
... \
--gpus all \
$DOCKER_IMAGE_NAME

(I’m actually not sure if :rw is supported, or if that’s just the default anyhow.)

And just in case you did not realize: the trailing backslash \ characters (without any whitespace after those) in your docker run command are only used to make things easier to read. In Linux, the following are often just the same:

some-command with a long list of options and arguments
some-command \
  with \
  a long list \
  of options \
  and arguments

See How to tell bash that the line continues on the next line - Stack Overflow.