OpenWrt hosts Lyrion Music Server (LMS) docker container

I know a lot of people (myself included) are interested in running LMS (Lyrion Music Server, aka. Logitech Media Server) on an OpenWrt router. Here I want to share how I did it and pitfalls I encountered in the process but first some background story.

Running LMS in a docker container wasn't my preferred method because the concern of extra hardware demands (amount of memory, disk space and CPU speed for the Docker Engine). My preferred method was to compile LMS under OpenWrt and run it directly under OpenWrt Linux but after some detailed investigation I realized that I don't have enough depth in Linux for this route. Also there is the question if it can really be done at all.

Now back to the topic. The router I used is a Linksys MR6350 which has 256MB of memory and 256MB of flash NAND which provides 64MB of root filesystem (disk space) for additional software packages. So the first thing to do is to add a USB storage drive and set up "extroot" environment. Follow the scripts in the Extroot configuration guide to accomplish this. But notice that the script (step. 2 Partitioning and Formatting) partitions the USB drive into a single partition. If that is what you want, it is fine. In my case I wanted three partitions - one for the root filesystem, one for storing my music files and one swap partition. So I partitioned and formatted my USB drive in my laptop with Debian 12 and skipped "step 2" of the guide. Important: if you skip "step 2", you need to define an environment variable "DEVICE=/dev/sda1" before the following steps. Make sure you do a reboot of the router after you finish all the extroot configuration steps for changes to take effective.

After reboot, I created a directory "/lms" in the root filesystem as the mount point for my music partion (/dev/sda2). I think it was done in LuCI->Mount tab. In stead of using the partition's UUID, I mounted it as a device "/dev/sda2".

For the swap partition I ran "mkswap -L swap /dev/sda3" and followed by "swapon /dev/sda3" in CLI. I ran the command "free -h" to make sure that the swap area actually existed before went back to LuCI->Nount tab to mount the swap partition. I then did another reboot and checked what I had done until now seemed to be there.

Now it was the time to setup OpenWrt as Docker container host. Basically here I installed the three packages (luci-app-dockerman dockerd docker) needed. The directories /opt and /opt/docker was created automatically after the packages were installed (probably by dockerd).

I then did what the OpenWrt Docker guide suggested, pulled the latest LMS image in CLI (docker pull lmscommunity/lyrionmusicserver). The LMS container webpage has a script to created the LMS container from the downloaded LMS image but some customization was needed. Here was my version of the script:

docker run --network=host -d \
      -v "/lms/config":"/config":rw \
      -v "/lms/music":"/music":ro \
      -v "/lms/playlist":"/playlist":rw \
      -e TZ="America/Los Angeles" \
      lmscommunity/lyrionmusicserver

I ran my container creation script after I had the corresponding subdirectories on my music partition first: /config, /music and /playlist. (I actually created /music and /playlist way back when the USB drive was still on the laptop for partitioning and formatting. I also had my music files copied then.) I wasn't sure where should be a good place for "/config" so the choice of it on my music partition (/dev/sda2) was arbitrarily. The LMS should run automatically after the container was created. Please pay attention to the container name in the script and the image name. When I downloaded the LMS image the "copy" button gave me "lmscommunity/lyrionmusicserver" but the container script on the same page had "lmscommunity/logimediaserver". So when I ran the container script, I was baffled why the script was downloading an image that supposedly I had downloaded just before. It turned out the pull command downloaded version 9.0 image (lmscommunity/lyrionmusicserver) but the container creation script was looking for version 8.5.2 image (lmscommunity/logitechmediaserver). So I ended up with two images and a wrong version of LMS container (8.5.2). The current lmscommunity web page had this mismatch corrected now. (The LMS 9.0 was released on Nov.28 but the web page didn't revised until a few says later and I was doing this in between.)

A comment on the network driver for the Dock Engine. I am running the LMS on a Dump AP and I have to use the "home" network driver (--network=home) in the container creation script to make the LSM works.

Running the LMS in a docker container incurs a ton of overhead. For one thing it consumes 3.6GB of the root filesystem (with two docker images and one docker container). Also at one point of time it used like 70MB of the swap area and it seems to be growing:). MR6350 apparently is not the right router for the LMS but I will keep it running and see how it fairs in the long run. I hope my new experience with the Docker helps someone who has the adequate OpenWrt hardware and wants to run the LMS on it.

1 Like

The disk space used by the docker container/image is actually somewhere around 220MB. I don't know what happened in my first installation. A week later I did the same installation on a MR8300 and found out that it used only 220MB. Surprised by the new finding, I redid the installation on MR6350 and got a similar 220MB usage. Here is a CLI screenshot:

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt 23.05.5, r24106-10cc5fcd00
 -----------------------------------------------------
root@MR6350:~#
root@MR6350:~# free -h
              total        used        free      shared  buff/cache   available
Mem:         248228      161248       26164          12       60816       39004
Swap:       1789948       80672     1709276
root@MR6350:~#
root@MR6350:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 4.0M      4.0M         0 100% /rom
tmpfs                   121.2M    184.0K    121.0M   0% /tmp
/dev/sda1               973.4M    212.1M    694.1M  23% /overlay
overlayfs:/overlay      973.4M    212.1M    694.1M  23% /
tmpfs                   512.0K         0    512.0K   0% /dev
/dev/sda2                 4.8G    223.9M      4.4G   5% /opt
/dev/sda3                48.9G     26.8G     19.6G  58% /lms
/dev/ubi0_1              65.9M      6.3M     56.2M  10% /rwm
/dev/sda2                 4.8G    223.9M      4.4G   5% /opt/docker
overlay                   4.8G    223.9M      4.4G   5% /opt/docker/overlay2/de52d86623298ea5de5f11f526a3ce773d0110f0cabde09edbf886f66c9700ad/merged
root@MR6350:~#

The setup uses about 80MB and I am okay with it. Nowadays flash drives are cheap. I think the one (64GB) I use currently cost me less then $5 and probably will last quite sometime.

Hi.
That's interesting.
I wonder if I can run LMS on dir-2660 (MT7621AT with 256DDR) USB2.0 and USB3.0
I wonder if I put USB DAC (sound card) can it play music? I use my dir-2660 as DUMB AP only.

You certainly can try. But LMS doesn't play media files. You need the squeezelite package (and kmod-usb-audio too). However I doubt the 2-core dir-2660 has the CPU power to handle both. Right now I run squeezelite on an ancient Netgear WNDR4300v2 (1 core at 775Mhz) and I can hear the pop sounds when I run Ookla speedtest with 2.4Ghz WiFi connection. The WNDR4300v2 connects to my internet carrier router through 5Ghz WiFi. This probably the worst case scenario because the WiFi driver demands CPU power and I use both radios at the same time.

Ok. Thx for reply.
I have lms on docker on thin client t620 HP.
I will try to connect usb sound card and make some test to play music from my primary LMS - dumb AP only play the music without docker with lms.

That would work. I used to have an HP T510 thin client running Debian but unloaded it after I found Virtualbox on the laptop is much more flexible (building OpenWrt firmware and other things that I need a linux machine).

My t620 is working as server with ubuntu server and a few of dockers. One of them is LMS, squezeelite with connected active speakers..
It's working great 3-4 years... with power consumption about 6-9W