Running Xorg on Raspberry Pi through Docker

  • Thanks to Irusak's awesome Docker addon we are now closer to running web browsers and other X11 apps on the Raspberry Pi. However, I'm having problems getting Xorg to work inside a container. Specifically, there is no output. I can launch Xorg just fine and it correctly chooses the framebuffer driver.

    Here's how I start my container:

    Code
    # docker run -it --privileged --name ubuntu -v /var/media:
    /media -v /var/run/dbus:/run/dbus armhf/ubuntu

    Here's the relevant Xorg log:

    It runs fine and I can launch Xorg apps, but the screen remains blank. This leads me to believe it's related to the fact that the Raspberry Pi does not have any virtual terminals enabled under LibreELEC/OpenELEC. In fact, if you boot with "tty" on the kernel command line, you can see debug-shell spawning a shell, but there is nothing displayed on the screen when doing "chvt 3".

    I've tried the same on Generic, and it works great. I can spawn X11 apps and have them display on the local X server, or run an X server in the container.

    Any ideas?

  • Yes it's possible, I can run Xorg server fine in a container on Generic. With Docker you can do anything that you can do in other distributions as long as your kernel supports it. The problem is with the RPi, Xorg is not displaying anything on the framebuffer. Some piece of the puzzle is missing, either a kernel option or perhaps in the device tree overlay.

    I'm unable to get a regular TTY displaying on the framebuffer as well under LibreELEC/OpenELEC. This is something that should definitely be possible.

    Looks like the kernel is bound to the dummy console:

    Code
    OpenELEC:~ # cat /sys/class/vtconsole/vtcon0/name 
    (S) dummy device
    OpenELEC:~ # cat /sys/class/vtconsole/vtcon1/name 
    (M) frame buffer device
    OpenELEC:~ # cat /sys/class/vtconsole/vtcon0/bind 
    1

    Trying to bind the console to the framebuffer like this:

    Code
    OpenELEC:~ # echo 1 > /sys/class/vtconsole/vtcon1/bind

    Results in a kernel crash:

    What I don't get is that during boot the Raspberry Pi framebuffer seems to work fine, as the boot logo is showing. During an update text is displayed on the console as well. If I boot with "debugging break=mount_storage" I get a debugging shell displayed on the framebuffer, and when I run fbset there it says the mode is "1824x984-0", but after a regular boot to Kodi and stopping Kodi, it says 1x1.

    It seems like when the Kodi target is reached, the console framebuffer is disabled somehow, and I believe this to be the reason. Hoping that someone has some insight on this.
    [hr]

    EDIT:

    I'm happy to report success, the problem was because of the fbset.service:

    Which reduces the size to 1x1 pixels. After a "fbset -g 1920 1080 1920 1080 32" I can start an X server and start Chromium. There is one remaining issue, I can't seem to use mouse/keyboard inside X. Will investigate further

    Edited once, last by escalade (May 1, 2016 at 7:51 PM).

  • More success! Xorg doesn't detect input devices because udev isn't working inside Docker. Solved by adding manual configuration in /etc/X11/xorg.conf.d/10-inputs.conf:

    Chromium segfaults for me both in Debian and in Arch, not sure what's up with that, but I got Firefox up and running so I'm happy :)

    • Official Post


    More success! Xorg doesn't detect input devices because udev isn't working inside Docker. Solved by adding manual configuration in /etc/X11/xorg.conf.d/10-inputs.conf:

    Chromium segfaults for me both in Debian and in Arch, not sure what's up with that, but I got Firefox up and running so I'm happy

    pretty cool. I'll setup a repo soon for dockerfiles related to LibreELEC. Then we can create one specifically for chromium or firefox.

  • Hey escalade!

    I am trying to run Firefox on my Pi with the information you provide.
    I am however new to Docker, and I have a hard time filling the gaps, eg:
    - the ubuntu/armhf image does not ship xorg and firefox, you have to install them
    - how should xorg and firefox be started
    - fbset.service is absent from LibreELEC and Ubuntu
    - etc

    Thank you in advance for any help

  • Hello escalade,

    I progressed a little:
    - in LE:
    - fbset -g 1920 1080 1920 1080 32 (to enable the frame buffer device)
    - systemctl stop kodi (to stop Kodi)
    - in the Docker container
    - apt install firefox xorg -y (to install Firefox and X.org)
    - startx -- :0 & (to start X.org)
    - DISPLAY=:0 firefox (to start Firefox)

    Firefox displays on the screen.
    I however had stop stop Kodi to display Firefox on the screen.
    I had copied the /etc/X11/xorg.conf.d/10-inputs.conf you provide, but the keyboard remained unresponsive.

    Had you managed to display Firefox on top of Kodi? Do you remember how?
    As for the keyboard, I have a feeling that a link is missing between LE and the container. What do you think.

    Thank you for any help further.

  • I stopped Kodi as well I think. Why would you want to run both? It's not like the Pi is powerful enough to play a video and browse at the same time. You'd need to release the audio device in any case, then Kodi is useless. Unless perhaps you installed Pulse, but again CPU power comes into play.

    As for the keyboard, I can't recall doing anything special to get it working. It definitely worked though. Are you sure that your 10-inputs.conf was read? I believe I used Arch, check that the path is the same for Ubuntu.

  • i'am sory, i'am newbie to LibreELEC and Docker.
    i just want to run Firefox in LibreELEC, then Google it, then i go to this thread.

    i have LibreELEC 7.0.2.007 running, the i go to add on , browse Kodi Addons, but i cannot find Docker add on in there....
    so how to install the add on?

    is there how to for newbie like me?

    Thanks...

  • Hey guys... I think I was able to run the official chromium browser from raapbian in dockers.
    I'm not really sure if it's decoding the video via hardware or not. But I think it is possible.

    I intend to write an addon to this but I'must kinda busy right now.

    Edited once, last by dead (October 5, 2016 at 6:42 PM).

  • Uploading a new version of the "chromium-elec". Pretty sure now it is working. :)
    It even has an cec input, but it is slow.

    Build the Dockerfile in the docker folder using:

    Code
    docker build -t chrome .

    Config.txt

    Code
    dtparam=audio=on
    disable_overscan=1

    Then just execute the run.sh

    It is using the mmal to accelerate the h264 decoding but unfortunately it doesn't work really well. (tested in a raspberry pi 2).


  • Uploading a new version of the "chromium-elec". Pretty sure now it is working. :)
    It even has an cec input, but it is slow.

    Build the Dockerfile in the docker folder using:

    Code
    docker build -t chrome .

    Config.txt

    Code
    dtparam=audio=on
    disable_overscan=1

    Then just execute the run.sh

    It is using the mmal to accelerate the h264 decoding but unfortunately it doesn't work really well. (tested in a raspberry pi 2).

    Hello dead!

    First, thank you for your efforts, they look promising.

    Then, I tried to follow your instructions, but run.sh fails with
    /bin/sh: 1: /tmp/run.sh: Permission denied
    I am running LE 7.90.006 for RPi2 on a RPi3.

    Finally, if I can make it work, I would like to wrap it in a addon.
    Do you intend to host the image on Docker Hub?

    Thank you for your help

  • Hello dead!

    First, thank you for your efforts, they look promising.

    Then, I tried to follow your instructions, but run.sh fails with
    /bin/sh: 1: /tmp/run.sh: Permission denied
    I am running LE 7.90.006 for RPi2 on a RPi3.

    Finally, if I can make it work, I would like to wrap it in a addon.
    Do you intend to host the image on Docker Hub?

    Thank you for your help


    Thanks!
    Feel free to write the addon, and yes, I intend to host the image on Docker Hub. :D
    I'm trying to improve the cec input right now.