user1419305
user1419305

Reputation: 488

XDummy in Docker container

I am trying to run a X11 server inside a docker container by using the XDummy driver. However, I have problems getting it to work. The intended purpose is to perform headless rendering. I can get it to work using Xvfb, but I need RANDR support, and eventually going to need GL support as well.

Dockerfile:

FROM node:slim

RUN mkdir nodeapp \
    && apt-get update \
    && apt-get install -y xorg \
    && apt-get install -y xserver-xorg-video-dummy x11-apps

COPY App /nodeapp/

ENV DISPLAY :1

RUN cd nodeapp/ \
    && npm install \
    && Xorg -noreset +extension GLX +extension RANDR +extension RENDER -logfile /nodeapp/xdummy.log -config /nodeapp/xorg.conf start :1 &

ENTRYPOINT [ "node", "/nodeapp/index.js" ]

The xorg.conf file is the basic Xdummy xorg.conf

However, the xserver does not boot, and the logfile does not provide anything useful, but I am certain I am doing something wrong when setting up Xorg in the Dockerfile, but I can't find any examples doing anything similar.

What is the recommended procedure to make this work?

Upvotes: 18

Views: 9977

Answers (2)

Bryan Larsen
Bryan Larsen

Reputation: 10006

I subscribe to the "one thing per container" Docker philosophy, so I modified your solution to only do XDummy. It can easily be linked to another container.

FROM debian:jessie

ENV DEBIAN_FRONTEND noninteractive
ENV DISPLAY :1

RUN apt-get update \
    && apt-get -y install xserver-xorg-video-dummy x11-apps

VOLUME /tmp/.X11-unix

COPY xorg.conf /etc/X11/xorg.conf

CMD ["/usr/bin/Xorg", "-noreset", "+extension", "GLX", "+extension", "RANDR", "+extension", "RENDER", "-logfile", "./xdummy.log", "-config", "/etc/X11/xorg.conf", ":1"]

And then to access, link the /tmp/.X11-unix volume and set DISPLAY=:1 in your environment.

Upvotes: 13

user1419305
user1419305

Reputation: 488

Managed to solve this, if anyone else is looking for a solution.

FROM node:slim

ENV DEBIAN_FRONTEND noninteractive
ENV DISPLAY :1

RUN mkdir nodeapp \
    && apt-get update \
    && apt-get -y install xserver-xorg-video-dummy x11-apps

COPY App /nodeapp/

RUN cd nodeapp/ \
    && npm install

ENTRYPOINT [ "node", "/nodeapp/index.js" ]

The problem was that apt-get was asking for keyboard config inside the docker container while installing, and that the dummy package provided all dependencies, so the regular xorg install was not needed.

The last issue was that I could not start Xorg and the nodeapp at the same time, but that was a easy fix. I already use node to manage services, so I moved the part starting Xorg into that.

var args = ["-noreset", "+extension", "GLX", "+extension", "RANDR", "+extension", "RENDER", "-logfile", "./xdummy.log", "-config", "/mplex-core/xorg.conf", ":1"];
this.proc = child_process.spawn("Xorg", args);

Upvotes: 8

Related Questions