Synology SMBv1 Docker container workaround

  • 18 October 2020
  • 67 replies
  • 5265 views

Userlevel 2
Badge

So I've got a Synology NAS and a couple of Sonos speakers. Some day I got the stupid (!) idea to switch SMBv1 off and soon I found out that my Sonos stuff was unable to find my local music library.

 

Of course I agree that Sonos should move to v2 or v3, but since there is no sign they will, even after the whole S2 operation, it seems we will have to solve this ourselves.

 

I’ve seen the Raspberry pi solution here on the forum, but I didn’t want separate devices and I thought it should be possible to do the same with docker on the NAS itself. If you are not familiar with Docker yet: it is like running an extra machine (called “container”) on your NAS, a little bit like virtual machines, but easier and more lightweight. The container runs isolated on your NAS, it only gets the access to your NAS you grant it specifically. Docker is a standard package on Synology. It also has a nice “registry”: an app store where everyone can share their containers.

 

So the idea is: run a container with SMB (Samba) v1 with read-only access to the music library on the Synology NAS only.

 

This workaround can almost completely be done from the DSM user interface!

 

Unfortunately you’ll need to enter one command on the command line. This is because standard Docker networking won’t suffice. Most containers use the IP-address of the host-machine (your NAS). I assume you want to keep Samba running on your NAS to access your (other) files on Windows and only upgrade it to a higher (more secure) version. This is why standard Docker networking won’t be enough here. Your container needs it’s own IP-address. This can be done with Docker macvlan networking, but there is no way to enable that from the user interface.

 

How to

 

Step 1 – install Docker

Login to your Synology NAS web interface (DSM) – you need to be administrator

  1. Open the Package Center
  2. In the Search field, search for docker
  3. Click Install on the Docker result

 

Step 2 – enable macvlan networking

As mentioned above, Docker containers usually don’t need their own IP-address, but in this case, it does. So your NAS will be connected to your network with only one cable, but it will have 2 IP-addresses. We need macvlan networking for this. With macvlan networking, Docker will supply your container with it’s own IP-address from  a designated pool of addresses, but all IP-address need to be on the same subnet!

Example IP-addresses

Your router: 192.168.0.1
Subnet: 255.255.255.0
Your Synology NAS: 192.168.0.2

 

Now your router will probably automatically supply computers on the network with IP-addresses (DHCP). Docker won’t listen to your router, but does this on it’s own. Therefore, you need a small range of IP-addresses that won’t be used by your router. In my case, my router manages IP-addresses from 192.168.0.1 to 192.168.0.200. So I can use anything between 192.168.0.201 to 192.168.0.254. I decided to use the end of the range: 192.168.0.240 – 192.168.0.254 which can also be described as 192.168.0.240/28. Many routers will be save using these high numbers, but please check your router settings to be sure and check the manual of necessary. Your network will become a mess if IP-addresses are used multiple times. If you can’t use 240-254, please Google subnet calculation to find another small range you could use.

 

To set this up in Docker, you need to login to the command line with SSH. On windows you can do this with Putty. You might need to enable SSH to do this. Settings are on the Control Panel under Terminal & SNMP.

After login just type (or copy here and paste in Putty using right mouse-click):

 

sudo docker network create --driver=macvlan --gateway=192.168.0.1 --subnet=192.168.0.1/24 --ip-range=192.168.0.240/28 -o parent=eth0 macvlan

 

And press enter. You will need to re-enter your password after this, because you are using sudo (to run administrative tasks)

 

After that, some random range of numbers will be shown. You’re done! Type “exit” and confirm with enter to leave.

 

Go back to the userinterface (DSM) en open Docker. Click on Network to confirm your macvlan network is there.

 

To find out more about Docker macvlan, see:

https://docs.docker.com/network/macvlan/

https://docs.docker.com/network/network-tutorial-macvlan/

https://collabnix.com/2-minutes-to-docker-macvlan-networking-a-beginners-guide/

 

Step 3 – download and launch Samba container

Now it’s time to download and launch your Samba container. Fortunately, several people have created Samba containers before, so you don’t have to create one yourself.

 

Click on Registry and type samba. First hit will be dperson/samba. This version is by far the most common. Select it by clicking on it and then hit download. A version selector will be shown, and latest is fine, so just continue. Download will start and will be ready soon, the image is pretty small.

 

Now go to Image. Here you will see all the images you downloaded and are waiting to be used. As long as the storage icon is changing, download is still in progress. A notification will pop up when download is ready. Select dperson/samba:latest and hit launch.

 

On the next screen, give your Container a nice name, like “sonos-samba” and you may want to limit resources. 512 MB should be enough.

 

Go to Advanced Settings and hit Enable auto-restart if you like. This will restart the container if it – for some reason – fails.

 

Then go the Volume and click Add Folder. Select the folder your music is stored. In general, this will be the “music” share. Make sure not to select any folder with anything private in it. So, if you store your music in your home folder, make sure not to select /homes/, but only select the subfolder containing music.

 

After this, in mount path, just type /music. And make sure to hit the Read-Only button. This way Docker will grant read-only access to this share. So even if your container gets compromised, it can’t hit anything on your Synology NAS.

 

Next go to Network. Make sure to remove Bridge (select and hit - ) and add your newly created macvlan network.

 

Port Settings and Links are fine, don’t touch.

 

Your share settings have to be added on the Environment-tab.

Although you might add the share as a public share, I prefer to use passwords anyway. Please make sure you use a generated password that you don’t use anywhere else!

 

Following Environment variables have to be set:

PATH 	= leave as is.
GLOBAL = ntlm auth = ntlmv1-permitted
# this will enable old authentication mechanism, necessary for Sonos
SMB = disable
# This will enable SMBv1
SHARE = music;/music;yes;yes;no;sonos;;;SonosMusic
# This is will add a share music, located at /music (location where you mounted your local music on the Volume page), read-only accessible for user sonos with description SonosMusic.
USER = sonos;verysecretgeneratedpassword12345

If you think you may need more settings, or want to understand these, please check the webpage of this container: https://hub.docker.com/r/dperson/samba

Click Apply.

Click Next

Click Apply.

Your container will now start!

 

After a few seconds you will be able to go to \\192.168.0.240\ (or any other IP-address you’ve set) in the windows explorer. You will need to enter sonos as username and your verysecretgeneratedpassword12345 as password and then you will see your music share and will be able to browse through your music collection.

 

If this works, go to your Sonos settings and add \\192.168.0.240\music as music library. If it connects properly, it will first start indexing. It’s a sign it is working and you can now safely remove the existing share pointing directly to your Synology NAS.

 

Don’t forget to turn SMBv1 off on your Synology! You can find it in the Control Panel under File Services. Click Advanced under SMB and change Minimum SMB protocol tot SMB2 or higher.


67 replies

Userlevel 2

Hi @samward, thank you for your feedback and we appreciate it. I'm glad that your Sonos is working perfectly

Please feel free to reach out to us if you have questions or if you need help with your Sonos system.

We will be glad to assist you.

@Rowena B. Just to clarify, I was able to get my Sonos to talk to my NAS by creating a separate server using outdated and insecure protocols.  Sonos MUST fix their SMB protocol - users should not have to go to these lengths just to listen to their own music.

Userlevel 2
Badge

Dear @Rowena B. ,

now that DSM7 is officially launched, i assume more and more people are getting stucked with SONOS SMB1 implementation. I think the solution that has been presented here is technically very good, but not what i expect to do, if i am working with one of the leaders in multiroom entertainment.

So i (and i think the most of your users) would really appreciate any information on when SONOS will update the software and go with  SMB2.


Hi gevaugeh, I agree, but there are a lot of topics with opinions about this. This is a topic about a solution and I like to keep it that way.

Userlevel 7
Badge +22

but it requires the PC to be on all the time

The particular NAS I was considering has an Intel Celeron running a modification of linux for the OS, so I thought it would be possible to port SonosLibraryService to that machine (it already runs many many apps).  Anyway, I have a working solution using my old Buffalo NAS that allows me to turn off my laptop and still hear SONOS music. A little extra work to add new music, but easy enough to do. Thanks very much for your insights on this for me...Jack


It would be easy to port the library service to any device that can run .Net Core - just decompile it to C# and recompile for the new target. Setup will probably be harder (ie getting the controller to add it to the system) and secrets management.

Userlevel 2
Badge

Have you mounted the folder inside the docker container?

 

Userlevel 2
Badge

vSwitch is off unfortunately.


I'm afraid I won't be of much help here. I suggest trying either Synology or Docker forums.

This works perfectly. Took a couple of attempts due to the fact it was the first time I've used Docker but it has given me a great introduction to docker/containers and also solved the problem of not having to enable smbv1 on my syno NAS and enabled me to share my music SAFELY from my NAS to Sonos. 

Follow the instructions accurately and it will work. Remember that when setting environment variables that the paths for the directory where you music is stored need to be exact i.e. case sensitive and don't miss the smb variable or you music folder will appear empty. I know because I made that mistake :)

 

Thanks for this workaround, top marks!

 

Userlevel 5
Badge +16

Hi @jelvank, thank you for sharing this with us, and welcome to the Sonos community.

We really appreciate you for providing descriptive information and the step-by-step procedure to address a similar issue. This will be helpful to our community users. Please continue sharing your experiences with us. 

Feel free to reach out to us or create a topic if you still have further questions or concerns. 

The Sonos Community is always here to help.

Userlevel 2

@jelvank Thank you so much for this - working perfectly

Userlevel 7
Badge +22

@mogbear based on those screenshots your PC is on an entirely different network to your NAS.

The PC is on 10.102.1.x (which is wireless) and your NAS is on 192.168.1.x

Zero chance these devices can see each other.

I know nothing about dockers (I just put my music on a PC, its trivial to setup and zero maintainance), but that network config is not going to work for Sonos.

 

Userlevel 2
Badge

Ok, this basically shows that your Docker container doesn't see any files. I think you should check the location of your music files, they might have moved after your HD migration. You can locate your music directory in Synology File Station and make sure the files are there. And check the Volume settings of your container and make sure it is pointing to the same location.

Badge +1

Ok, this basically shows that your Docker container doesn't see any files. I think you should check the location of your music files, they might have moved after your HD migration. You can locate your music directory in Synology File Station and make sure the files are there. And check the Volume settings of your container and make sure it is pointing to the same location.

@jelvank Thank you for all your help…. I got it to work...I guess it is my lack of knowledge of Docker and how all this works, it turns out the problem was this whole process is CAPS specific. 

My music share folder is Music and I was doing everything in lower case, assuming that CAPS didn’t matter. 

Made changes to everything to match all the CAP letters and everything is working as you designed.

Again, thanks for your help and this secure fix that Sonos FAILS to address and fix properly. 

@jelvank great write-up! I put containerizing this off for almost a year (just got into the Sonos family during late 2020), but your guide made me do it ASAP because, well...I didn’t have any excuses.

Some other words for everybody else:

  • You can definitely do more shares and have your music in different folders. Use SHARE, SHARE2, SHARE3, etc. I have 5 shares and they work perfectly (as long as you do it correctly - make a volume, use that volume name in the share, etc.)
  • If you’re only going to be running this container, I suggest using a very small IP range like /31 instead of /28. /31 does 2 IP addresses and 28 does 8. Small difference, but my IP ranges are constrained because I have a ton of devices on my wifi (smart home things).
  • 512 MB is totally enough. I’m running 24 bit 48 kHz flacs without any issues
  • Using the built-in Sonos library is the only way to get 24-48 flacs playing on your speakers. Plex is capped at 16 bit. An alternative would be to set up another script using ffmpeg to convert your 24 bit → 16 bit, use Plex with the 16 bit, and call it a day.
  • If you have to delete the macvlan you created, got back to SSH and use the sudo docker network rm macvlan - why would you do this? Maybe you messed up your IP ranges like I did and need to fix it *shrug*

Userlevel 2
Badge

I'm stuck. I am a complete noob when it comes to command line. I have never done it on my new Synology DS920+ or previously my old DS412+. I am trying do the Sonos workaround and I just can't figure it out.

How do I know what IP address the Docker uses my IP range is 10.220.30.xxx, so I can point Sonos to it, plus I have 2 folders with music.

Please refer to step 2 in the description. You will need to replace:

sudo docker network create --driver=macvlan --gateway=192.168.0.1 --subnet=192.168.0.1/24 --ip-range=192.168.0.240/28 -o parent=eth0 macvlan

with ip-adresses matching your situation. I have to guess that:

Your router = 10.220.30.1?

And your subnet is on anything between 10.220.30.1 - 10.220.30.254?

And that address 10.220.30.240 is free?

If so, your command will be:

sudo docker network create --driver=macvlan --gateway=10.220.30.1 --subnet=10.220.30.1/24 --ip-range=10.220.30.240/28 -o parent=eth0 macvlan

And the ip of your docker/samba machine will be 10.220.30.240

 

Userlevel 2
Badge

1. is Music and 2. HD Music AIFF. I tried to do share SHARE = music;/music;yes;yes;no;sonos;;;SonosMusic and SHARE = music;/HD Music AIFF;yes;yes;no;sonos;;;SonosMusic

 

Docker didn’t like the 2 shares so I did SHARE = music;/HD Music AIFF/music;yes;yes;no;sonos;;;SonosMusic

 

Like I said, I’m a complete noob at this! 

  1. You can't add 2 folders under the same name. Add the music folder with the name music and the other with (for example) hdmusicaiff.
  2. Make sure to add both folders in the Volume tab in your docker settings (refer to step 3 in manual above)
  3. Start trying to get it to work on share music alone. This is the easy one.
  4. You can easily see if it works by connecting to the share from Windows explorer. Go to \\10.220.30.240 and if it works, you should see the shared folders.
  5. For HD Music AIFF: I guess the command doesnt like spaces in the directory name. It probably works by escaping spaces with “\”: SHARE = hdmusicaiff;/HD\ Music\ AIFF/music;yes;yes;no;sonos;;;SonosMusic
  6. If you get both shares to work separatly, please refer to https://hub.docker.com/r/dperson/samba to see how to add more shares. Under Configuration NOTE2, it says you should be able to do so by adding SHARE2 =
Userlevel 7
Badge +22

So, I just ran an experiment with my new laptop: I turned off the Windows Feature SMB 1.0/CIFS (I had previously turned it on). I then asked the SONOS app to index my Windows Music folder. It worked fine, and, in fact, was the fasted indexing I have ever experienced. Music played fine. Why does this work without SMB1 activated? I thought the SONOS system needed SMB1.

I was about to buy a Sonology DS220+ (It’s already in my Amazon cart!!!), but this thread is scaring me away from that. 


Sonos does not use SMB for PC or Mac local file access (stopped that a few years ago), it uses a local http server called SonosLibraryService. Sonos only use SMB for networked devices such as NAS and the device you are considering purchasing.

Dear @Rowena B. ,

now that DSM7 is officially launched, i assume more and more people are getting stucked with SONOS SMB1 implementation. I think the solution that has been presented here is technically very good, but not what i expect to do, if i am working with one of the leaders in multiroom entertainment.

So i (and i think the most of your users) would really appreciate any information on when SONOS will update the software and go with  SMB2.

Badge

Is there a possibility to configure the samba container in a way that it broadcasts a friendly name instead of accessing it via the ip address?

Userlevel 2
Badge

I’m sure this is a crazy question, however, where do I change the setting to “world readable”? Somewhere in Docker, or Control Panel> Users and Groups? 

I unselected “Read Only” in docker and no change...

In Control Panel (Synology) → Shared Folders → select folder → edit → tab permissions

And are you sure de location of your music files is still the same?

I don't know if you are used to using the command line, but you can check if your docker container can even see anything by opening a terminal on the terminal tab in your Docker details. Hit Create and enter:

cd /music
ls -alF

This should return a list of all files and directories including ownership and permissions.

(Don't forget to change Read-only back)

Userlevel 1
Badge

but it requires the PC to be on all the time

The particular NAS I was considering has an Intel Celeron running a modification of linux for the OS, so I thought it would be possible to port SonosLibraryService to that machine (it already runs many many apps).  Anyway, I have a working solution using my old Buffalo NAS that allows me to turn off my laptop and still hear SONOS music. A little extra work to add new music, but easy enough to do. Thanks very much for your insights on this for me...Jack

Userlevel 7
Badge +21

Add the IP / name translation to your router’s DNS settings if nothing else.

Badge +1

@jelvank yes I did, each version I would go add the folder under Volume

Thank you, @jelvank! Excellent post.

I was about to enable SMBv1 on my NAS when I saw your post. Everything works perfectly.

It’s a shame that Sonos forces us to go through these workarounds.

Userlevel 2
Badge

@jelvank yes I did, each version I would go add the folder under Volume

Ok, maybe description should be unique too. Your SHARE= comment basically consists of a lot of fields:

name;/path[;browse;readonly;guest;users;admins;writelist;comment]

So in your case try changing SonosMusic to SonosMusicAIFF:

HD_Music_AIFF;/HD_Music_AIFF;yes;yes;no;sonos;;;SonosMusicAIFF

 

Badge +1

Well, everything was working like a champ THANK YOU!!!!  Until I upgraded HDDs on my NAS, the ones I had in service were 7 years old, so I figured it is a good idea to get “modern” HDDs. In doing so I backed up my old drives, but the Docker setting didn’t get backed up somehow.

I’ve redone the docker and I get connected to the folders in docker (music and hd_music) via Mac Finder no problem and Sonos shows I’m connected too. 

The problem is when I view either folder in either Mac Finder or Sonos (to create new playlists or just browse in Sonos) neither of my folders show any files. 

I can go directly into DiskStation or Mac Finder and view the folders and files fine. I can play songs the whole bit. 

Any idea why through docker  or Sonos neither folder shows any files? 

Userlevel 1
Badge

Well, I think I’m in a good place now: I did get that new NAS (Asustor AS5202T 2-bay), and I have successfully moved my Music Folder over to it. Using SMB1 enabled, I set up a new library in the SONOS app that points to the Music folder on the NAS. As long as I don’t want to change the structure of the SONOS library, I can disable SMB1 and still update the music files and the .m3u playlist files just by copy things from my PC to the NAS. I then re-index the SONOS library, and I don’t need SMB1 to do that step. Seems to work fine. Thanks for your insights and suggestions on all this. 

Reply