You are not logged in.

#1 2015-03-01 17:17:21

mascip
Member
Registered: 2015-02-10
Posts: 29

cannot run X apps in a docker container

Hi, I have a Dockerfile which enables me to run X apps.
It works perfectly in Ubuntu, but not in Archlinux:

FROM mascip/archlinux:2014.12.09

# To avoid a bug with the filesystem: https://registry.hub.docker.com/u/base/arch/
RUN sed 's/^CheckSpace/#CheckSpace/g' -i /etc/pacman.conf

# BROWSERS
RUN pacman --noconfirm -S nvidia-libgl && pacman --noconfirm -S leafpad

# NON-ROOT USER
# Replace you uid, gid, and username
RUN pacman --noconfirm -S sudo
RUN export uid=1000 gid=1000 && the_user="abla" && \
    the_home="/home/${the_user}" && \
    the_capital_user=$(echo $the_user | sed 's/./\U&/') && \
    mkdir -p $the_home && \
    echo "${the_user}:x:${uid}:${gid}:${the_capital_user},,,:/${the_home}:/bin/bash" >> /etc/passwd && \
    echo "${the_user}:x:${uid}:" >> /etc/group && \
    echo "${the_user} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/${the_user} && \
    chmod 0440 /etc/sudoers.d/${the_user} && \
    chown ${the_user}:${the_user} -R ${the_home}

# Replace username and home
ENV USER abla
ENV HOME /home/abla
WORKDIR /home/abla

USER abla

CMD /usr/bin/leafpad

In order to run it, I do:

$ docker build -t a1 .

$  docker run -ti \
-e DISPLAY -e XAUTHORITY=/tmp/.Xauthority -v /home/user/.Xauthority:/tmp/.Xauthority -v /tmp/.X11-unix:/tmp/.X11-unix \
a1 leafpad

which works in Ubuntu (a Leafpad window opens), but not in Arch where I get:

leafpad: Cannot open display:

PS: I have a similar Docker container which runs leafpad in a Ubuntu container; the problem is exactly the same for that container too.
PPS: the Dockerfile stems from here: http://fabiorehm.com/blog/2014/09/11/ru … th-docker/
Edit: I need to make it work soon. I would appreciate any idea to investigate further. I find X11 magic very confusing.

Last edited by mascip (2015-03-02 14:09:58)

Offline

#2 2015-03-02 06:57:31

mascip
Member
Registered: 2015-02-10
Posts: 29

Re: cannot run X apps in a docker container

I have tried checking that the Xserver was running with

$ ps aux | grep X

and it wasn't (is that even possible, as things were displaying on my screen?)

So I installed the whole xorg group:

$ sudo pacman -Sy xorg

After that, startx wouldn't start anymore, and I had to upgrade everything:

$ sudo pacman -Syu

which fixed the problem.

Now the X server is running:

$ ps aux | grep X
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
root       335  0.8  1.0 289376 42688 tty1     Ssl+ 06:46   0:01 /usr/lib/xorg-server/Xorg :0 -seat seat0 -auth /run/lightdm/root/:0 -nolisten tcp vt1 -novtswitch
user       459  0.0  0.2 304648  9980 ?        Ssl  06:46   0:00 /usr/bin/lxsession -s LXDE -e LXDE
user       531  0.4  0.6 497908 24460 ?        Sl   06:47   0:00 lxpanel --profile LXDE
user       532  0.2  0.8 607376 34960 ?        Sl   06:47   0:00 pcmanfm --desktop --profile LXDE
user       944  0.0  0.0  10712  2256 pts/1    S+   06:49   0:00 grep --color=auto X

but Leafpad still won't be displayed and throws the same error.

Any more ideas?

Last edited by mascip (2015-03-02 08:04:26)

Offline

#3 2015-03-02 18:09:29

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: cannot run X apps in a docker container

Moving to Apps and DEs...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

Board footer

Powered by FluxBB