Docker Community Forums

Share and learn in the Docker community.

Python GUI App inside a container

docker

(Ish) #1

Hi all,

I’m trying to run a GUI application written in Python and Kivy language in Debian/Jesse, but have run into an issue when trying to run the container.
So, I wrote the Docker file, built the image and getting this issue when the container starts to run halfway through. By the looks of it, the problem is related to building a connection between host machine and the container for SDL2 /X11. Would be very much appreciated if someone could give some guide lines. I have shared the my Dockerfile and error below.
Thanks in advance.

Dockerfile -

FROM resin/rpi-raspbian:jessie

RUN apt-get update && apt-get install -y
libsdl2-dev
libsdl2-image-dev
libsdl2-mixer-dev
libsdl2-ttf-dev
pkg-config
libgl1-mesa-dev
libgles2-mesa-dev
python-setuptools
libgstreamer1.0-dev
git-core
python-dev
gcc
python-pip
gstreamer1.0-plugins-base
gstreamer1.0-plugins-good
gstreamer1.0-plugins-bad
gstreamer1.0-plugins-ugly
gstreamer1.0-alsa
gstreamer1.0-omx
xclip
libmtdev-dev
python-pygame

RUN pip install cython

RUN pip install git+https://github.com/kivy/kivy.git@master

ENV XDG_RUNTIME_DIR=/run/user/1000

ADD animate.py /

CMD [“python”,“animate.py”]

Error log is below -

pi@raspberrypi:~/dockTest $ docker container run kivydock
[WARNING] [Config ] Older configuration version detected (0 instead of 20)
[WARNING] [Config ] Upgrading configuration in progress.
[INFO ] [Logger ] Record log in /root/.kivy/logs/kivy_18-01-16_0.txt
[INFO ] [Kivy ] v1.10.1.dev0, git-00c161d, 20180115
[INFO ] [Python ] v2.7.9 (default, Sep 17 2016, 20:26:04)
[GCC 4.9.2]
[INFO ] [Factory ] 194 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignored)
[INFO ] [Text ] Provider: sdl2
[INFO ] [OSC ] using for socket
[INFO ] [Window ] Provider: sdl2([‘window_egl_rpi’] ignored)
[CRITICAL] [Window ] Unable to find any valuable Window provider.
egl_rpi - ImportError: cannot import name bcm
File “/usr/local/lib/python2.7/dist-packages/kivy/core/init.py”, line 59, in core_select_lib
fromlist=[modulename], level=0)
File “/usr/local/lib/python2.7/dist-packages/kivy/core/window/window_egl_rpi.py”, line 12, in
from kivy.lib.vidcore_lite import bcm, egl

sdl2 - RuntimeError: No available video device
File “/usr/local/lib/python2.7/dist-packages/kivy/core/init.py”, line 67, in core_select_lib
cls = cls()
File “/usr/local/lib/python2.7/dist-packages/kivy/core/window/window_sdl2.py”, line 140, in init
super(WindowSDL, self).init()
File “/usr/local/lib/python2.7/dist-packages/kivy/core/window/init.py”, line 960, in init
self.create_window()
File “/usr/local/lib/python2.7/dist-packages/kivy/core/window/window_sdl2.py”, line 272, in create_window
self.fullscreen, resizable, state)
File “kivy/core/window/_window_sdl2.pyx”, line 93, in kivy.core.window._window_sdl2._WindowSDL2Storage.setup_window
File “kivy/core/window/_window_sdl2.pyx”, line 66, in kivy.core.window._window_sdl2._WindowSDL2Storage.die

x11 - ImportError: No module named window_x11
File “/usr/local/lib/python2.7/dist-packages/kivy/core/init.py”, line 59, in core_select_lib
fromlist=[modulename], level=0)

[CRITICAL] [App ] Unable to get a Window, abort.


(Sam) #2

there is no window for x… you would have to start the container, then attach to it, set the display port, and then start x… the container is headless


(Ish) #3

Thanks for the reply! @sdetweil
Are you suggesting something like this ?
docker run -i -t -e DISPLAY -v /tmp/.X11-unix kivydock


(Sam) #4

no

docker run -d -name foo whatever parms
docker attach foo
then at the commandline do whatever

I don’t believe there is an automated way to do this…

basiclaly you have to open a tty window AFTER the container is running and then
get X going…

the docker model is the containers are servers, with no UI.