0
  • How to restart the ROS docker container with GUI enabled? (Points to note: restart & with GUI!)

Following from questions like this and this and the docker tutorial for ROS here I managed to stumble on to how one can "run" a docker container with GUI enabled.

It goes something like this:

$ xhost +local:docker
$ docker run -it --env="DISPLAY" --env="QT_X11_NO_MITSHM=1" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" --volume="$HOME/.Xauthority:/root/.Xauthority" ros

Afterwards, I can run inside the container in a terminal the following commands:

# roscore

And then in a separate terminal:

$ docker exec -it priceless_engelbart bash
# apt-get update
# apt-get install ros-melodic-rqt-gui
# rosrun rqt_gui rqt_gui

And a window appears, which shows that the GUI is working from inside the container.

enter image description here

Question: The problem is, I don't want to create a new container every time, which is what the docker run command does. I have done work in the first container. Why would I want to completely ignore that and spin up a new container and start from scratch?

To remedy the situation, I looked into docker start, docker restart, docker attach and docker exec, to see if there was anyway to pass those extra parameters that I pass to docker run, like --env and --volume to help make the GUI work inside the container here.

Unfortunately, those commands do NOT allow passing any such parameters.

I have not been able to find a solution till now for the situation.

Duck Dodgers
  • 3,409
  • 8
  • 29
  • 43
  • 1
    Docker start simply restarts the container using same settings as were passed using the Docker run. – Mike Doe Mar 02 '20 at 16:34
  • Yes, you are right. In the 9 min since I posted this question, I tested that scenario. But what about the container where I did not 'run' the container with the gui specific parameters? – Duck Dodgers Mar 02 '20 at 16:52
  • You have to recreate the container. Use `docker-compose` instead. If any settings are changed it will recreate container for you, no need for low level `docker run` command. – Mike Doe Mar 02 '20 at 18:20
  • 1
    @emix, ok. I try out docker-compose. Thank you for the hint. `:)` – Duck Dodgers Mar 03 '20 at 07:23
  • This [answer](https://stackoverflow.com/a/26833005/2955790) explains the solution to my problem and also the fundamental misunderstanding of mine regarding containers. I should not be storing data in the container that I depend on. – Duck Dodgers Mar 03 '20 at 14:16

0 Answers0