Customized Docker Images

  • Hello!

    I've been using OSMC instead of LibreELEC for years because I needed some additional OS features on my Raspberry Pi. Now I've upgraded to the RPi5 and was appalled to find that OSMC has no support for it. Some research revealed that LibreELEC now offers a powerful Docker integration. That is amazing! Yesterday I installed LibreELEC with the Docker/LinuxServer.io addon and pulled the nginx container image from LinuxServer.io. Everything works great so far (thanks!!) and I am very excited about the entire configuration management via Samba shares (for LibreELEC and for the containers). But now I'm stuck because I don't know how to configure the container to establish the services I had in OSMC:


    1. From inside the LinuxServer.io nginx container, I want to store files on a physical drive mounted in LibreELEC. How do I have to change the settings.xml for this?

    Code
    <setting id="V_config" default="true">/storage/.kodi/userdata/addon_data/docker.linuxserver.nginx/config</setting>

    I naively tried <setting id="V_something">/var/media/mydisk/Downloads</setting>, but docker inspect -f '{{ .Mounts }}' ... shows only the config mount.


    2. I need one or two additional packages in my container, like ffmpeg. I've read that LibreELEC does all container management (updates and restarts) automatically, which is incredibly convenient. What is the easiest (most "lightweight") way to add two or three additional packages to the nginx base container without having to renounce LibreELEC's automatic restart/update features?


    3. In the long run, I would like to have another "generic" (maybe Debian based) container for some mini-services and scripts. I assume I have to create my own Docker constainer image. But I haven't figured out how I would add this container to LibreELEC.


    I've searched the Github LinuxServer.io nginx repo and I read LinuxServer.io docker addons and general docker info. But I was unable to answer these questions. Please excuse me if I missed something.


    Thanks a lot!

    Steffen

  • OK I found the perfect documentation for questions 1 and 2: https://docs.linuxserver.io/general/container-customization/ Funny they give the same example with ffmpeg there 😀

    Answer to 1 (bind mount additional host directories) and 2 (install additional packages):

    Create two directories for custom startup scripts and additional services:

    Bash
    # the directories need to be owned by root
    mkdir /storage/.kodi/userdata/addon_data/docker.linuxserver.nginx/custom-cont-init.d
    mkdir /storage/.kodi/userdata/addon_data/docker.linuxserver.nginx/custom-services.d

    Edit the settings.xml

    Code
    <setting id="E_additional">-v /storage/.kodi/userdata/addon_data/docker.linuxserver.nginx/custom-cont-init.d:/custom-cont-init.d -v /storage/.kodi/userdata/addon_data/docker.linuxserver.nginx/custom-services.d:/custom-services.d</setting>

    Put a script which installs the required packages in /storage/.kodi/userdata/addon_data/docker.linuxserver.nginx/custom-cont-init.d. The example from linuxserver.io for installing ffmpeg:

    Bash
    #!/bin/bash
    
    
    echo "**** installing ffmpeg ****"
    apk add --no-cache ffmpeg

    Reboot LibreELEC (to have the settings.xml reloaded), and check

    Bash
    # the two directories should show up here
    docker exec -it nginx bash -c "ls /"
    # check ffmpeg (should print /usr/bin/ffmpeg)
    docker exec -it nginx bash -c "which ffmpeg"
  • I wouldn't recommend manually editing the settings.xml. Just edit the addon settings in the gui.

    I agree. But I found this much easier compared to using the TV remote with Kodi's horrible visual keyboard (where I accidentally hit CANCEL at the end of typing 80% of the time due to its immature behavior). I found that LibreELEC doesn't read the settings.xml after the change, hence the hint to do a quick reboot.

    For installing a package, using our package install mod is much easier

    Ah, thanks! The setup script is perfect for me (very easy and effective), but I see the need and many benefits of a standardized way.

    Thanks!