How to open a rviz, a qt application, in vscode-remote?

Viewed 28

I am trying to run a ros project inside a vscode-remote container where the images would be running on the current machine. It needs to be able to communicate to other nodes outside of the containers and able to use vizualisation tools like rviz which uses qt library.

I installed nvidia-docker2 and was able to start the image on it's own and start rviz. However when running the command in vscode-remote, some parameters don't seem to work.

This is the command I used to run my image using cli:

docker run -it --rm \
        --name noetic_desktop \
        --hostname noetic_desktop \
        --device /dev/snd \
        --env="DISPLAY" \
        --env="QT_X11_NO_MITSHM=1" \
        --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
        -v `pwd`/../Commands/bin:/home/user/bin \
        -v `pwd`/../ExampleCode:/home/user/ExampleCode \
        -v `pwd`/../Projects/catkin_ws_src:/home/user/Projects/catkin_ws/src \
        -v `pwd`/../Data:/home/user/Data  \
        -env="XAUTHORITY=$XAUTH" \
        --gpus all \
        noetic_image:latest \
        bash

And this is the config I am running for vscode-remote extension. devcontainer.json :

{
    "name": "Existing Dockerfile",

    "context": "..",

    "dockerFile": "../Dockerfile",

    "runArgs": ["--env='DISPLAY'","--gpus all"],

    "containerEnv": {
        "QT_X11_NO_MITSHM": "1",
        "XAUTHORITY": "${localEnv:XAUTH}"
    }

}

For opening the image in cli I am doing :

docker run -it --rm \
        --name noetic_desktop \
        --hostname noetic_desktop \
        --device /dev/snd \
        --env="DISPLAY" \
        --env="QT_X11_NO_MITSHM=1" \
        --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
        -v `pwd`/../Commands/bin:/home/user/bin \
        -v `pwd`/../ExampleCode:/home/user/ExampleCode \
        -v `pwd`/../Projects/catkin_ws_src:/home/user/Projects/catkin_ws/src \
        -v `pwd`/../Data:/home/user/Data  \
        -env="XAUTHORITY=$XAUTH" \
        --gpus all \
        noetic_image:latest \
        bash

However when I try to open it in vscode I get an unknown flag on the gpu argument.

Start: Run: docker run --sig-proxy=false -a STDOUT -a STDERR --mount type=bind,source=/home/crossing-laptop/Documents/Code/docker/ros-in-container,target=/workspaces/ros-in-container --mount type=volume,src=vscode,dst=/vscode -l devcontainer.local_folder=/home/crossing-laptop/Documents/Code/docker/ros-in-container -e QT_X11_NO_MITSHM=1 -e XAUTHORITY= --env='DISPLAY' --gpus all --entrypoint /bin/sh vsc-ros-in-container-ea1fa5d968381e26dee62839190e6131-uid -c echo Container started
unknown flag: --gpus all

For reproduce ability, you can find the files at https://github.com/tomkimsour/ros-in-container.

0 Answers
Related