Here you can find detailed instructions on how to run a dockerized MiniDLNA Server with docker-compose and create a systemd service to handle it.
Docker
Make sure to have Docker and Docker-compose installed. For Debian Linux you just need to install the following packages.
apt update && apt install -y docker-ce docker-compose
Docker application location
In order to run the container we need to create a location eg: /opt/containers/minidlna and store our configuration in there.
mkdir -p /opt/containers/minidlna
Configuration
In order to run the MiniDLNA server we need to specify the following environment variables
- GROUP_ID=0 is mandatory and specifies the user ID (UID) that will run the server
- USER_ID=0 is mandatory and specifies the group ID (GID) that will run the server
- MINIDLNA_PATH is mandatory and specifies the path in the Host for the container data
- MEDIA_PATH is mandatory and specifies the path in the Host where the multimedia files reside in
/opt/containers/minidlna/.env defines all necessary environment variables
GROUP_ID=0
USER_ID=0
MINIDLNA_PATH=/opt/containers/minidlna
MEDIA_PATH=/media
Compose File
/opt/containers/minidlna/docker-compose.yml defines the services, networks, and volumes for the MiniDLNA Docker application
Make sure to have the following directories in the media location Images, Music, Photos and Videos or else you need to edit the compose file and remove the appropriate environment and volume entries.
version: "3"
services:
minidlna:
restart: always
image: vladgh/minidlna:latest
network_mode: "host"
environment:
- PUID=${USER_ID}
- PGID=${GROUP_ID}
- MINIDLNA_MEDIA_DIR_1=PV,/media/Images
- MINIDLNA_MEDIA_DIR_2=A,/media/Music
- MINIDLNA_MEDIA_DIR_3=PV,/media/Photos
- MINIDLNA_MEDIA_DIR_4=V,/media/Videos
- MINIDLNA_DB_DIR=/minidlna/cache
- MINIDLNA_LOG_DIR=/minidlna/log
- MINIDLNA_FRIENDLY_NAME=DLNA-server
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
- ${MEDIA_PATH}/Images:/media/Images:ro
- ${MEDIA_PATH}/Music:/media/Music:ro
- ${MEDIA_PATH}/Photos:/media/Photos:ro
- ${MEDIA_PATH}/Videos:/media/Videos:ro
- ${MINIDLNA_PATH}/cache:/minidlna/cache
- ${MINIDLNA_PATH}/log:/minidlna/log
Systemd service definition
/etc/systemd/system/docker-compose-mininidlna.service defines the service that starts and stops the Docker application for the system
[Unit]
Description=MiniDLNA container
Requires=docker.service
After=docker.service
[Service]
Type=simple
WorkingDirectory=/opt/containers/miniDLNA
ExecStart=/usr/bin/docker-compose up --force-recreate --remove-orphans
ExecStop=/usr/bin/docker-compose down
[Install]
WantedBy=default.target
Enable and run service
source /opt/containers/minidlna/.env && mkdir -p "${MINIDLNA_PATH}/log" "${MINIDLNA_PATH}/cache"
systemctl daemon-reload && \
systemctl enable docker-compose-minidlna && \
systemctl start docker-compose-minidlna
Visit MiniDLNA page
You should be able to visit your container at port 8200 using the Host IP. eg: https://127.0.0.1:8200