Difference between revisions of "Docker"

From Sundtek Wiki
Jump to navigation Jump to search
(4 intermediate revisions by the same user not shown)
Line 12: Line 12:
  
 
If you want to install the linux driver in a docker environment a few things need to be taken care of.
 
If you want to install the linux driver in a docker environment a few things need to be taken care of.
In this example a tvheadend Docker is installed on a Synology NAS:
+
 
 +
==== Device Nodes on the Host ====
 +
 
 +
Very important /dev/bus/usb contain the interface to the raw USB devices which is used by the sundtek driver.
 +
However one special (and a little bit messy part of docker) is that it also needs to know the major/minor IDs which are allowed to be forwarded - before creating and before starting the docker image, that's why nodes in /dev/dvb need to be pre-created on the host.
 +
 
 +
If you install the driver on the host you should create a configuration file which contains following text:
 +
enabledocker=on
 +
 
 +
this will cause that the driver on the native host (not in the docker) will create dummy adapter nodes in /dev/dvb, the driver itself will not try to access the USB device - it will only create the files if enabledocker=on is set in the configuration file and exit immediately.
 +
 
 +
You can also create them manually if you want (see next section):
 +
 
 +
===== Without installing the driver on the host =====
 +
 
 +
So the driver on the host has no special function it would just create /dev/dvb devicenodes and exist immediately.
 +
You can create those dummies manually (but those need to be there before creating the docker image and before starting the docker image)
 +
 
 +
<pre>
 +
mkdir -p /dev/dvb/adapter0
 +
mknod /dev/dvb/adapter0/frontend0 c 212 1
 +
mknod /dev/dvb/adapter0/dvr0 c 212 5
 +
mknod /dev/dvb/adapter0/demux0 c 212 3
 +
mkdir -p /dev/dvb/adapter1
 +
mknod /dev/dvb/adapter1/frontend0 c 212 7
 +
mknod /dev/dvb/adapter1/dvr0 c 212 11
 +
mknod /dev/dvb/adapter1/demux0 c 212 9
 +
mkdir -p /dev/dvb/adapter2
 +
mknod /dev/dvb/adapter2/frontend0 c 212 13
 +
mknod /dev/dvb/adapter2/dvr0 c 212 17
 +
mknod /dev/dvb/adapter2/demux0 c 212 15
 +
</pre>
 +
 
 +
===== Synology NAS =====
 +
 
 +
You can install the driver on the host and check the option "Enable Docker" in the Configuration menu. When this is checked the driver will only create those dummy nodes on the host and exit immediately.
 +
 
 +
==== Creating a Docker Image ====
  
 
The docker itself needs to be created with some -device flags
 
The docker itself needs to be created with some -device flags
Line 25: Line 62:
 
                     -t alpine /bin/sh  
 
                     -t alpine /bin/sh  
 
</pre>
 
</pre>
 
Very important /dev/bus/usb because this contains the interface to the raw USB devices which is used by the sundtek driver.
 
However one special (and a little bit messy part of docker is that it also needs to know the major/minor IDs which are allowed to be forwarded, that's why /dev/dvb needs to be pre-created on the host as dummy files.
 
 
The driver on the host should have a configuration file which contains following text:
 
enabledocker=on
 
 
this will cause that the driver on the native host (not in the docker) will create dummy adapter nodes in /dev/dvb, the driver itself will not try to access the USB device - it will only create the files if enabledocker=on is set in the configuration file.
 
  
 
=== Inside the docker ===
 
=== Inside the docker ===

Revision as of 06:44, 5 February 2021

Docker

External Documentation

  • Synology Wiki (German):

https://www.synology-wiki.de/index.php/TvHeadend_mit_Docker_und_Sundtek_SkyTV_Ultimate

On the host

This is the step that has to be taken care about on the native host (outside of the docker image). The driver can run in non-privileged mode inside the docker. Various libc / musl / uclibc images are supported.

If you want to install the linux driver in a docker environment a few things need to be taken care of.

Device Nodes on the Host

Very important /dev/bus/usb contain the interface to the raw USB devices which is used by the sundtek driver. However one special (and a little bit messy part of docker) is that it also needs to know the major/minor IDs which are allowed to be forwarded - before creating and before starting the docker image, that's why nodes in /dev/dvb need to be pre-created on the host.

If you install the driver on the host you should create a configuration file which contains following text: enabledocker=on

this will cause that the driver on the native host (not in the docker) will create dummy adapter nodes in /dev/dvb, the driver itself will not try to access the USB device - it will only create the files if enabledocker=on is set in the configuration file and exit immediately.

You can also create them manually if you want (see next section):

Without installing the driver on the host

So the driver on the host has no special function it would just create /dev/dvb devicenodes and exist immediately. You can create those dummies manually (but those need to be there before creating the docker image and before starting the docker image)

mkdir -p /dev/dvb/adapter0
mknod /dev/dvb/adapter0/frontend0 c 212 1
mknod /dev/dvb/adapter0/dvr0 c 212 5
mknod /dev/dvb/adapter0/demux0 c 212 3
mkdir -p /dev/dvb/adapter1
mknod /dev/dvb/adapter1/frontend0 c 212 7
mknod /dev/dvb/adapter1/dvr0 c 212 11
mknod /dev/dvb/adapter1/demux0 c 212 9
mkdir -p /dev/dvb/adapter2
mknod /dev/dvb/adapter2/frontend0 c 212 13
mknod /dev/dvb/adapter2/dvr0 c 212 17
mknod /dev/dvb/adapter2/demux0 c 212 15
Synology NAS

You can install the driver on the host and check the option "Enable Docker" in the Configuration menu. When this is checked the driver will only create those dummy nodes on the host and exit immediately.

Creating a Docker Image

The docker itself needs to be created with some -device flags

docker create --name alpinelinux 
                     --net=bridge 
                     -p 9981:9981 
                     -p 9982:9982 
                     --device=/dev/dvb 
                     --device=/dev/bus/usb 
                     -t alpine /bin/sh 

Inside the docker

Inside the docker unfortunately you only have one shot if you do it wrong you have to re-create the docker and re-do this step. Usually our customers install the drivers inside the docker in /config

Download the netinstall script:

wget http://sundtek.de/media/sundtek_netinst.sh
chmod 777 sundtek_netinst.sh
./sundtek_netinst.sh -docker -use-custom-path /config

The installer will rename the tvheadend binary in /usr/bin to tvheadend.bin and places a script instead which will automatically start the driver.

this will place the driver in /config

Usually you will want to mount a local directory inside the docker, this can basically be configured via the Synology Webfrontend. When doing that you need to take care that the user inside the docker also has access to that folder otherwise you will get a permission denied.

You can use the tvheadend start script to change the permissions if you need that, /usr/bin/tvheadend add chmod 777 /path/to/videodirectory

Misc

one customer also needed to modify the preset current limit of the tuner, he had to place lnblimit=1000ma (case sensitive in sundtek.conf inside the docker)