Running GUI in docker (no ssh, no VNC)

TL;DR: root is not supposed to run GUI app, set a regular user to do so.

I’m trying to run arduino IDE (downloaded, not the package) from within a Docker. I wrote the Dockerfile as follow:

  • How to use Docker in Windows ?
  • Random tag applied to every git commit
  • How to connect two HA group containers in Bluemix?
  • Making the Docker Registry HA
  • What does it mean for a Docker environment variable to not have a name?
  • Docker won't start on Windows: Not Enough memory to start docker
  • FROM ubuntu:14.04
    MAINTAINER Mael Auzias <docker@mael.auzias.net>
    
    ENV HOME /home/arduino
    ENV USER arduino
    
    RUN apt-get update && apt-get install -y \
       libx11-6 libxext-dev libxrender-dev libxtst-dev \
        --no-install-recommends \
        && useradd --create-home --home-dir $HOME $USER \
        && chown -R $USER:$USER $HOME
    
    ADD arduino-1.6.6-linux64.tar.xz $HOME
    
    WORKDIR $HOME/arduino-1.6.6
    USER $USER
    
    ENTRYPOINT ["/bin/bash"]
    

    I spent time to understand how does Jessica Frazelle usually starts her graphical containers to rightly start mine with the command:

    $docker run --name arduino --rm -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix 25af73b6cb3c ./arduino
    No protocol specified
    Picked up JAVA_TOOL_OPTIONS: 
    No protocol specified
    Exception in thread "main" java.awt.AWTError: Can't connect to X11 window server using ':0' as the value of the DISPLAY variable.
    

    I installed strace and check with xeyes what was wrong, and I get the following error:

    connect(3, {sa_family=AF_LOCAL, sun_path=@"/tmp/.X11-unix/X0"}, 20) = -1 ECONNREFUSED (Connection refused)
    

    Did anyone experience this? Can any point me out some doc or see what I’m doing wrong?

    Any help would be welcome.

    PS: as specified in the title I do not want to use ssh or VNC. No cryptography should be used nor network when a unix socket is faster and enough.


    Solution

    Got some news…

    As the user root I cannot start graphical application. When I su regular-user and start xterm or xeyes it works. I don’t really understand why though :/


    Here is the working Dockerfile, tested on Fedora 23.
    The application must not be ran as root so it starts using X.
    Note that, unrelated to this issue, a Java option has been removed from the bash file arduino (so it starts properly).

    After a docker build -t arduino-1.6.6 ., docker run --name arduino --rm -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix arduino-1.6.6 ./arduino start the arduino IDE.

    You will not be able to upload any code into an arduino without adding a --device or -v to share the /dev/ttyUSB0.

    FROM ubuntu:14.04
    MAINTAINER Mael Auzias <docker@mael.auzias.net>
    
    ENV HOME /home/arduino
    ENV USER arduino
    
    RUN apt-get update && apt-get install -y \
            libx11-6 libxext-dev libxrender-dev libxtst-dev \
            --no-install-recommends \
            && rm -rf /var/lib/apt/lists/* \
            && useradd --create-home --home-dir $HOME $USER \
            && chown -R $USER:$USER $HOME
    
    ADD arduino-1.6.6-linux64.tar.xz $HOME
    RUN sed -i 's/"-Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel"//g' /home/arduino/arduino-1.6.6/arduino
    
    WORKDIR $HOME/arduino-1.6.6
    USER $USER
    
    ENTRYPOINT ["/bin/bash"]
    

  • Laradock (docker) keeps throwing http error 500
  • Docker best practices for security [closed]
  • Automate adding new repository tags to Docker Registry Automated Build
  • Memory issues when running Keras inside Docker on a Mac
  • Protractor e2e tests with bitbucket pipelines
  • Redis Docker - Unable to connect from C# client
  • One Solution collect form web for “Running GUI in docker (no ssh, no VNC)”

    Got some news…

    As the user root I cannot start graphical application. When I su regular-user and start xterm or xeyes it works. I don’t really understand why though :/


    Here is the working Dockerfile, tested on Fedora 23.
    The application must not be ran as root so it starts using X.
    Note that, unrelated to this issue, a Java option has been removed from the bash file arduino (so it starts properly).

    After a docker build -t arduino-1.6.6 ., docker run --name arduino --rm -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix arduino-1.6.6 ./arduino start the arduino IDE.

    You will not be able to upload any code into an arduino without adding a --device or -v to share the /dev/ttyUSB0.

    FROM ubuntu:14.04
    MAINTAINER Mael Auzias <docker@mael.auzias.net>
    
    ENV HOME /home/arduino
    ENV USER arduino
    
    RUN apt-get update && apt-get install -y \
            libx11-6 libxext-dev libxrender-dev libxtst-dev \
            --no-install-recommends \
            && rm -rf /var/lib/apt/lists/* \
            && useradd --create-home --home-dir $HOME $USER \
            && chown -R $USER:$USER $HOME
    
    ADD arduino-1.6.6-linux64.tar.xz $HOME
    RUN sed -i 's/"-Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel"//g' /home/arduino/arduino-1.6.6/arduino
    
    WORKDIR $HOME/arduino-1.6.6
    USER $USER
    
    ENTRYPOINT ["/bin/bash"]
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.