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:

  • Does Kubernetes (local Docker method) really work?
  • jq returns null from curl
  • gcloud ping attempt failure with performing a 'docker push'
  • Deploy Docker from Travis to AWS (or any other SSH able server)
  • Where could I find docker-standard environment variables like DOCKER_HOST?
  • Do I need my own server if I move my Elastic Beanstalk app to use 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"]
    

  • Stop VM with MongoDB docker image without losing data
  • Error response from daemon: (config) includes invalid characters for a local volume name
  • Docker Postgres data volume on the host
  • Docker Registry vs Nexus/Artifactory
  • django docker-compose --> memcached not working
  • How to deploy app in this meteor docker image?
  • 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.