How to run root docker image with graphics

I’m trying to use docker with graphics as described here:
https://hub.docker.com/r/rootproject/root
but when I try the recommended command:

docker run -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --rm -it --user $(id -u) rootproject/root root

and try for example to open a TBrowser, I get:


TBrowser B;
Warning in <TBrowser::TBrowser>: The ROOT browser cannot run in batch mode

Does calling xhost local:root on your host machine before starting the docker image work?

This works for me on Arch Linux:

$ xhost local:root
$ docker run -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --rm -it --user $(id -u) rootp
roject/root root
  ------------------------------------------------------------------
  | Welcome to ROOT 6.26/00                        https://root.cern |
  | (c) 1995-2021, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on Mar 03 2022, 06:51:13                 |
  | From tags/v6-26-00@v6-26-00                                      |
  | With c++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0                    |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'       |
   ------------------------------------------------------------------

root [0] TBrowser b
(TBrowser &) Name: Browser Title: ROOT Object Browser

Sadly, it doesn’t work for me on CentOS Linux release 7.9.2009

xhost local:root

docker run -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --rm -it --user $(id -u) rootproject/root root
Unable to find image 'rootproject/root:latest' locally
Trying to pull repository docker.io/rootproject/root ... 
latest: Pulling from docker.io/rootproject/root
7c3b88808835: Already exists 
bd343703c096: Already exists 
d55caf47e2c4: Already exists 
59a11f64db52: Already exists 
Digest: sha256:a3cd8f4ba9d22ebcd3a8a0d40c46c6fdda401d556b04f0f9cd115dba40519b38
Status: Downloaded newer image for docker.io/rootproject/root:latest
   ------------------------------------------------------------------
  | Welcome to ROOT 6.26/00                        https://root.cern |
  | (c) 1995-2021, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on Mar 03 2022, 06:51:13                 |
  | From tags/v6-26-00@v6-26-00                                      |
  | With c++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0                    |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'       |
   ------------------------------------------------------------------

root [0] TBrowser B;
Warning in <TBrowser::TBrowser>: The ROOT browser cannot run in batch mode

@ajfinch If it is your “private” machine. Try to install and use “singularity” (from “EPEL”). It can use docker containers, and I also remember people had no problems with X11.

Thanks, that worked! I just did
singularity run docker://rootproject/root root

Thanks @Wile_E_Coyote for the workaround, I’m happy that worked.

We’ll have to check what the correct magic spell to have docker work is on CentoS, apparently it works differently from the platforms I could test on – so thanks for the report!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.