MiniDLNA On Your NAS

Streaming media is something I do often. I don’t need much, but it does need to be stable and just
work 😄!

MiniDLNA

In 2010 I wrote a blog about the mediatomb DLNA server and that I would not be working with it anymore, because my NAS (Synology) has the functionality build in.

Here are some updates as I have had some trouble with it all.

It appears that the MediaServer software for the Synology NAS is not as stable as I had hoped. During a movie it would often crash and had to restart and re notify before being found by the TV again. So I disabled that and moved to Serviio which is very feature complete but also many meant for gui users.

I’ve build multiple docker images for serviio and it worked fine for some time, but after the update to v2.x I again had encountered lots of instability issues, crashes and the like.

If you are like me and just want to stream a movie or series over your home network to your TV without having to connect hard disks and the like, most DLNA software is just doing to much. I wanted something simple but effective.

After some searching I found MiniDLNA. It seemed dead but I see some updates now and again happening. It does not pretend to do more than just DLNA. Just what I was looking for 😄.

So lets see of a docker image would work. This is what I came up with:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
FROM alpine:3.11
ARG VERSION=1.0
LABEL org.label-schema.name="MiniDLNA server" \
org.label-schema.description="MiniDLNA" \
org.label-schema.url="https://ivonet.nl/" \
org.label-schema.vcs-url="https://github.com/ivonet/docker-minidlna" \
org.label-schema.version=$VERSION \
org.label-schema.schema-version="1.0" \
maintainer="Ivonet - @ivonet"
RUN apk --no-cache add minidlna bash tini
COPY minidlna.conf /etc/minidlna.conf
COPY entrypoint.sh /entrypoint.sh
ENV MINIDLNA_FRIENDLY_NAME="IvoNet DLNA" \
MINIDLNA_NOTIFY_INTERVAL=30 \
MINIDLNA_MEDIA_DIR="V,/videos"
VOLUME ["/minidlna"]
EXPOSE 1900/udp
EXPOSE 8200
ENTRYPOINT ["/sbin/tini", "--", "/entrypoint.sh"]

The concept is really simple and the 0.1 version was only a few lines but also not configurable.
Here is the configuration script I made:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
[ -f /var/run/minidlna/minidlna.pid ] && rm -f /var/run/minidlna/minidlna.pid
for VAR in $(env); do
if [[ "$VAR" =~ ^MINIDLNA_ ]]; then
if [[ "$VAR" =~ ^MINIDLNA_MEDIA_DIR ]]; then
minidlna_name='media_dir'
else
minidlna_name=$(echo "$VAR" | sed -r "s/MINIDLNA_(.*)=.*/\\1/g" | tr '[:upper:]' '[:lower:]')
fi
minidlna_value=$(echo "$VAR" | sed -r "s/.*=(.*)/\\1/g")
echo "${minidlna_name}=${minidlna_value}" >> /etc/minidlna.conf
fi
done
exec /usr/sbin/minidlnad -d "$@"

This script will extend a basic config file with parameters retrieved from environment variables

  • minidlna.conf
1
2
3
4
5
6
7
8
9
port=8200
db_dir=/minidlna
album_art_names=Cover.jpg/cover.jpg/AlbumArtSmall.jpg/albumartsmall.jpg/AlbumArt.jpg/albumart.jpg/Album.jpg/album.jpg/Folder.jpg/folder.jpg/Thumb.jpg/thumb.jpg
inotify=yes
enable_tivo=no
strict_dlna=no
serial=87654321
model_number=1
# Custom config will be below

The script will search for all environment variables starting with MINIDLNA_ and act by either creating extra scan-able media_dir entries or other configuration entries. Some entries have been given a default, but can be overridden.

I’ve been testing it f a couple of weeks now and have not had any crashes yet. The interface is very basic, but suits my needs perfectly. Simple but very effective.

The whole docker image is 68Mb and that is also much better than my previous 300Mb for Serviio. It is completely open source.

Hopefully it will keep on performing as it does.
In that case I might be a happy customer for a long time…

Example (very complete) run command:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/env bash
docker run \
-d \
--name minidlna \
--net=host \
-v "$(pwd)/config:/minidlna" \
-v "/volume2/video:/videos" \
-e MINIDLNA_FRIENDLY_NAME="FooBarBaz DLNA" \
-e MINIDLNA_NOTIFY_INTERVAL=10 \
-e MINIDLNA_MEDIA_DIR_DOWNLOADS="V,/downloads" \
-v "/volume2/downloads:/downloads" \
-e MINIDLNA_MEDIA_DIR_MUSIC="A,/music" \
-v "${HOME}/Music:/music" \
-e MINIDLNA_MEDIA_DIR_PICTURES="P,/pics" \
-v "${HOME}/Pictures:/pics" \
ivonet/minidlna

Cheerz,
Ivo.

References: