sbungartz / cooja-docker

Docker container to run the Contiki Cooja simulator
https://hub.docker.com/r/sbungartz/cooja
MIT License
10 stars 1 forks source link

Setting correct DISPLAY variable #1

Closed vSecDev closed 2 years ago

vSecDev commented 3 years ago

Hi, I get the error below. Tried setting the DISPLAY variable to :0.0, :0, and all sorts of other combinations, including w IP and hostname. Nothing seems to work. I am trying to run cooja in a docker container on Kali Linux with and without external monitors. Any idea what may be the issue?

[java] Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8 [java] No protocol specified [java] Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable. [java] at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method) [java] at sun.awt.X11GraphicsEnvironment.access$200(X11GraphicsEnvironment.java:65) [java] at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:110) [java] at java.security.AccessController.doPrivileged(Native Method) [java] at sun.awt.X11GraphicsEnvironment.(X11GraphicsEnvironment.java:74) [java] at java.lang.Class.forName0(Native Method) [java] at java.lang.Class.forName(Class.java:195) [java] at java.awt.GraphicsEnvironment.createGE(GraphicsEnvironment.java:102) [java] at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:81) [java] at sun.awt.X11.XToolkit.(XToolkit.java:120) [java] at java.lang.Class.forName0(Native Method) [java] at java.lang.Class.forName(Class.java:195) [java] at java.awt.Toolkit$2.run(Toolkit.java:869) [java] at java.security.AccessController.doPrivileged(Native Method) [java] at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:861) [java] at sun.swing.SwingUtilities2.getSystemMnemonicKeyMask(SwingUtilities2.java:1928) [java] at javax.swing.plaf.basic.BasicLookAndFeel.initComponentDefaults(BasicLookAndFeel.java:752) [java] at javax.swing.plaf.metal.MetalLookAndFeel.initComponentDefaults(MetalLookAndFeel.java:433) [java] at javax.swing.plaf.basic.BasicLookAndFeel.getDefaults(BasicLookAndFeel.java:148) [java] at javax.swing.plaf.metal.MetalLookAndFeel.getDefaults(MetalLookAndFeel.java:1588) [java] at javax.swing.UIManager.setLookAndFeel(UIManager.java:536) [java] at javax.swing.UIManager.setLookAndFeel(UIManager.java:576) [java] at javax.swing.UIManager.initializeDefaultLAF(UIManager.java:1345) [java] at javax.swing.UIManager.initialize(UIManager.java:1455) [java] at javax.swing.UIManager.maybeInitialize(UIManager.java:1422) [java] at javax.swing.UIManager.getInstalledLookAndFeels(UIManager.java:416) [java] at org.contikios.cooja.Cooja.setLookAndFeel(Cooja.java:1238) [java] at org.contikios.cooja.Cooja.main(Cooja.java:3167) [java] Java Result: 1

sbungartz commented 3 years ago

Hi,

  1. Make sure you are actually running Xorg / X11. It is starting to be replaced by Wayland, so if your distro already uses that, the method from this repo will not work.
  2. Make sure you have set the --net host and -e DISPLAY options with the docker run command, as described in the README. When you have a physical Monitor attached it should work.
  3. When you do not have a physical monitor, you have multiple options depending on what you want to achieve. You could use a virtual monitor like xvfb (as explained here for example, or xvnc if you want to see the gui from another machine, or try and setup x11 forwarding or something.
  4. If you just want to interact with Cooja on the command line and really do not need the gui, maybe there is a flag in cooja to disable the gui. I have not worked with Cooja since 2017 so I don't know, but if that exists, maybe you don't need to bother with any of the above stuff at all.

I hope some of this helps :)

vSecDev commented 2 years ago

Hi,

Apologies for the delayed response and thank you for the advice. Step 2. seems to have fixed it for me :) As I'm learning to configure the simulations, I find the GUI helpful.

Best :)