Git Product home page Git Product logo

docker-x-server's Introduction

X Server in Docker

X Server running in Docker - can be used on a headless (no GUI) Linux installation like Ubuntu server connected to a display. Great for building media-centers (like Kodi) plugged into your home TV or kiosk-like appliances (run Chrome with whatever content you like).

Requires --privileged flag when running a container.

Building image

docker build . -t docker-x-server:latest

You can start container either in privileged mode:

docker run --name docker-x-server --privileged docker-x-server:latest

Or my granting SYS_TTY_CONFIG capability and mapping a few video related devices:

docker run --name docker-x-server --device=/dev/input --device=/dev/console --device=/dev/dri --device=/dev/fb0 --device=/dev/tty --device=/dev/tty1 --device=/dev/vga_arbiter --device=/dev/snd  --device=/dev/psaux --cap-add=SYS_TTY_CONFIG docker-x-server:latest

If you pass an argument, it would be executed using xinit which allows you to test it quickly by say running xeyes

docker run --name docker-x-server --device=/dev/input --device=/dev/console --device=/dev/dri --device=/dev/fb0 --device=/dev/tty --device=/dev/tty1 --device=/dev/vga_arbiter --device=/dev/snd  --device=/dev/psaux --cap-add=SYS_TTY_CONFIG docker-x-server:latest /usr/bin/xeyes

If you need input (like keyboard or mouse) you also need to bind /run/udev/data folder to your container:

docker run --name docker-x-server --device=/dev/input --device=/dev/console --device=/dev/dri --device=/dev/fb0 --device=/dev/tty --device=/dev/tty1 --device=/dev/vga_arbiter --device=/dev/snd  --device=/dev/psaux --cap-add=SYS_TTY_CONFIG  -v /run/udev/data:/run/udev/data docker-x-server:latest

Advanced

If on whatever reason you do not want to use udev for input methods, find the event number for your keyboard (like /dev/input/event4), uncomment the relevant section in Dockerfile, update the Device Option for keyboard accordingly and rebuild the image.

Usage

Easiest way to use image, is to extend it. For example if you want to run jellyfin-mpv-shim in Docker, your Dockerfile might look like this:

FROM docker-x-server:latest

RUN apt-get update && apt-get install -y python3-pip libmpv1 libavformat-dev

RUN pip3 install --upgrade jellyfin-mpv-shim

RUN printf "\
OUTPUT=\`xrandr -display :0 -q | sed '/ connected/!d;s/ .*//;q'\`\n\
xrandr -display :0 --output \$OUTPUT --set \"Broadcast RGB\" \"Full\"\n\
xsetroot #000000\n\
xset s off -dpms\n\
/usr/local/bin/jellyfin-mpv-shim\n\
" > /usr/local/bin/jellyfin-mpv-shim-wrapper

RUN chmod +x /usr/local/bin/jellyfin-mpv-shim-wrapper

CMD /usr/bin/xinit /usr/local/bin/jellyfin-mpv-shim-wrapper -- :0 -nolisten tcp vt1

Another option is to run the actual application in separate container and share the X11 socket between them:

docker volume create --name xsocket
docker run --name docker-x-server --device=/dev/input --device=/dev/console --device=/dev/dri --device=/dev/fb0 --device=/dev/tty --device=/dev/tty1 --device=/dev/vga_arbiter --device=/dev/snd  --device=/dev/psaux --cap-add=SYS_TTY_CONFIG  -v xsocket:/tmp/.X11-unix  -v /run/udev/data:/run/udev/data -d  docker-x-server:latest
docker run --rm -it -e DISPLAY=:0 -v xsocket:/tmp/.X11-unix:ro stefanscherer/xeyes

docker-x-server's People

Contributors

bedrin avatar lanealucy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

docker-x-server's Issues

Support RPi

Might require adding --device="/dev/vchiq"

do not use --privileged mode

We can map following devices instead (either with --device or with --device AND --volume):
/dev/input
/dev/console
/dev/dri
/dev/fb0
/dev/tty*
/dev/nvidiactl
/dev/nvidia-uvm
/dev/nvidia0
/dev/vga_arbiter
/dev/snd

With alsa /dev/snd can only be used from single container

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.