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?
NAME. Xdummy - A hack to run Xorg or XFree86 X server with the "dummy" video driver.
What Is a Dockerizing. Dockerizing is the process of packing, deploying, and running applications using Docker containers. Docker is an open source tool that ships your application with all the necessary functionalities as one package.
The Docker daemon ( dockerd ) listens for Docker API requests and manages Docker objects such as images, containers, networks, and volumes. A daemon can also communicate with other daemons to manage Docker services.
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.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With