Docker based KODI/VDR (nvidia)

I was using http://www.yavdr.org/ for several years and what i learned was that the dependencies in the packages of a mediacenter can be a pain. Several times i wished to be able to do a rollback after a update.

It has improved a lot, but sometimes i am still getting problems when running updates. As i am using Docker every day for my work at INSPIRATIONlabs i decided to try to create a mediacenter on top of Docker.

I will describe how i installed a HTPC with Kodi and LiveTV with VDR.

What’s already done:

1. Base installation of Debian jessie (we want systemd) + Xorg configuration + nvidia-driver installation
2. Xserver autostart on host system
3. Xserver authorization on host

Kodi and Xorg installation

Base installation

I did a minimal installation of Debian 8.1.
After installing the base system i installed the xserver core and the nvidia drivers and configured the Xorg — server. This is not yet part of this guide.

To get the latest Docker version it should be installed with:
curl -sSL https://get.docker.com/ | sh

Xserver autostart on host system

I wanted to start a minimal Xserver on system launch. I know that i will not win a beauty contest with my configuration as i am running everything as root but to be true: I was not sure if this will work and decided to do the installation with minimal effort as possible.

To start the X — Window on boot. I created a system — init — script in /etc/systemd/system/X11.service.

[Unit]
Description=‘startx’
After=getty@tty1.service

[Service]
Type=simple
ExecStart=/usr/bin/startx — -nocursor

[Install]
WantedBy=getty@tty1.service

After saving the script, i enabled it with
systemctl enable X11

Xserver authorization on host

I added
DISPLAY=:0
to the /etc/environment

Additionally i created a ~/.xsessionrc with the following content:
export DISPLAY=:0
xhost +SI:localuser:root
xsetroot -gray
xset s off # don’t activate screensaver
xset -dpms # disable DPMS (Energy Star) features.
xset s noblank # don’t blank the video device

Docker build

manual build

As the official Kodi repository uses ubuntu ppa’s i decided to use phusion/baseimage (a minimal ubuntu 14.04 for Docker) as Baseimage for my installation.

After i failed a few times with my installation (my Debian host and my Ubuntu host had different nvidia-driver versions) i found the repository from Matt McCormick [https://github.com/thewtex/docker-opengl-nvidia]. I created a new repository at [https://github.com/DominicBoettger/docker-kodi-nvidia] and changed the build process a bit to reflect my configuration.

If the driver version is not exactly the same as on the Docker host you will get a error like that:

```
X Error of failed request: BadValue (integer parameter out of range for operation)
X Error of failed request: GLXBadContext Major opcode of failed request: 154 (GLX) Minor opcode of failed request: 24 (X_GLXCreateNewContext)
```

To build the image the git repository should be checked out first.

git clone https://github.com/DominicBoettger/docker-kodi-nvidia.git .

Now go to the checked out folder and execute the Build script
cd docker-kodi-nvidia
./build.sh

After the build has been successful Kodi can be startet with
./run.sh — name kodi -p 8080:8080 kodi-nvidia

automatic build

This build can be used if the Host system is running nvidia-driver version 340.65 ( like Debian Jessie ).

This should return 340.65
cat /proc/driver/nvidia/version | head -n 1 | awk ‘{ print $8 }’

Then you can run kodi with these commands:

```
XSOCK=/tmp/.X11-unix docker run \ -v $XSOCK:$XSOCK:rw \ — device=/dev/dri/card0:/dev/dri/card0 \ — device=/dev/nvidia0 \ — device=/dev/nvidiactl \ — device=/dev/snd:/dev/snd \ -e DISPLAY=$DISPLAY \ — name kodi -p 8080:8080 dominicboettger/kodi-nvidia
```

VDR installation

DVB Driver

I am using a dual channel DVB card. Mystique Satix S2 Dual. So this is more for my configuration than for yours. Just install the driver of your card if not supported out of the box.

apt-get install libproc-processtable-perl
cd /usr/src
curl -O http://www.dvbsky.net/download/linux/media_build-bst-14-141106.tar.gz
tar xvzf media_build-bst-14–141106.tar.gz
cd media_build-bst-14/
./v4l/build_x64.sh
make
make install
cd dvbsky-firmware/
./bst-firmware.sh

reboot

VDR

To start the VDR just enter:

docker run -d — name vdr — device=/dev/dvb:/dev/dvb -p 8008:8008 -p 37890:37890 -p 6419:6419 -p 3000:3000 -p 34890:34890 dominicboettger/vdr

The image will be downloaded and executed.

To start it with systemd you can add the following script in /etc/systemd/system/vdr.service

[Unit]
Description=VDR container
Requires=docker.service
After=X11.service

[Service]
Restart=always
ExecStart=/usr/bin/docker start -a vdr
ExecStop=/usr/bin/docker stop -t 2 vd

[Install]
WantedBy=graphical.target

To active the init script execute this command:
systemctl enable vdr

After VDR is running Kodi can be configured to use the IP of the VDR server.

I am really happy with the status of the project and it’s much more than i ever expected to be able to solve with Docker.

Like what you read? Give dboettger a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.