Docker is a containerization system. It allows you to run programs or apps in a self contained container, with its own OS, while sharing the host system’s resources, and in some cases libraries and devices.
LinuxServer.io’s docker images and containers can be thought of as mini virtual machines that are much lighter and more efficient than full blown VMs.
LinuxServer.io provides pre-built docker images that can be pulled from the docker hub. These images contain the necessary packages and apps and are either Alpine or Ubuntu Xenial based. A user can pull one of these images, create a container based on the image and run it to perform the tasks. Containers are ephemeral, meaning they can be easily destroyed and recreated from the docker image. For things that are meant to be persistent, like data, volume mounts are used.
LibreELEC is a Just enough Operating System (JeOS), meaning it only contains the necessary packages and libraries for the main purpose, which is Kodi. It does not contain a package manager. If one wants to install an app that requires mono, or java, those dependencies would have to be compiled for LibreELEC (not an easy task). However, with docker, one could pull a docker image and create a container that already contains all of these dependencies, and is sandboxed from LibreELEC.
Containers can be created via various methods. The simplest is through command line. The following command creates a container for running an nginx based webserver on LibreELEC:
“docker create --name=nginx -v /storage/nginx:/config -e PGID=100 -e PUID=65534 -p 80:80 -p 443:443 -e TZ=America/New_York linuxserver/nginx”
The “-v” is used to define mount points. The left side is the host side, and the right side is the container side. Son in the above case, /storage/nginx folder on LibreELEC can be accessed inside the container at /config.
The “-e” is used to define environment variables. Above, we tell the container to set the PUID to 65534, which means the webserver will run as user “nobody” on LibreELEC. And the Group id will be set to 100, which is “users”.
The “-p” defines the ports that are mapped. Again, the left side is for host and the right is for the container. Above example maps 80 to 80, but if one wants to serve the pages on port 85 instead, they would replace the above parameter with the following: “-p 85:80” so request on port 85 in LibreELEC will be forwarded to port 80 on the container.
The last element is the name of the image on docker hub. On first run, docker will download the necessary image layers from the hub, and will extract them, which can take some time for larger images especially on slower systems. Then it will create the container named nginx. One can start the container by the command “docker start nginx” and the webserver on port 80 (or 85) should come up.
We know that command line is not the friendliest method especially for a media center UI. LinuxServer.io created addon wrappers to make it extremely easy for users to manage docker containers. Simply install the LinuxServer.io repo from the LibreELEC addon repositories, then you can install various docker addons from the LinuxServer.io repo.
Once installed, the addon wrapper automatically downloads and extracts the images, sets the default parameters and creates the container. Most addons work out of the box just fine, some may require additional settings. For instance the DuckDNS docker addon, which is for updating the IP on DuckDNS’s dynamic dns service, will only set up and start the container after the user enters their subdomain and token info in the addon settings. Most docker addons allow the user to change the settings for ports and volume mount (persistent data) locations as well as app specific settings.