I have an ARM64-based Synology NAS device and have been trying to set up Docker on it using the instructions found here:
Can I install Docker on arm8 based Synology Nas
However, the fact that I can’t use the default bridge network mode but instead have to use host mode (network_mode=host
) is preventing me from doing some things that I’d like to do. In the aforementioned thread user P Leo writes:
Please note, you need to set storage drive vfs, iptables off, bridge
off due to a Linux kernel problem. And you need to run docker
container with –network=host mode. It is not usual, but it is
necessary due to Synology NAS kernel limitations.
I was wondering if anyone could shed more light on this apparent limitation? Based on other Synology- and Docker-related discussions online, it seems that it doesn’t affect some users. Is the issue perhaps limited to ARM-based devices or specific Linux kernel versions (my device has 4.4.180+)? And most importantly, is there really no way around it?
Thanks in advance for any help!
2
Answers
The answer is Yes that you Can use completely docker functionality on ARM-based Synology NAS, including bridge functionality.
Before you use it, you need complete the missed .ko driver files for the Synology NAS linux kernel.
You can follow the steps in https://www.v2ex.com/t/850768#reply2 to complete all missed .ko files. Then you can run Docker with full functionality on ARM-based Synology NAS.
I’ve done this recently on a DS218 that has an arm64 (RTD1296) CPU. It’s a bit involved but doable.
Start Docker in
bridge
ModeFirst thing, check if your NAS has the necessary kernel modules in
/usr/lib/modules
. Mine did, so load them in this order:(If you see a
File Exists
error, ignore it; it just means the module has already been loaded.)Then check if
iptables
can match byaddrtype
orconntrack
sincedockerd
needs both.If you see an error such as
No such file or directory
, you have work to do. You can either install a version ofiptables
that’s not crippled from Entware (opkg install iptables
), or you can compile the missing libs yourself. I did the latter on my Mac:The compile failed for me, but it produced the 2 libs
libxt_addrtype.so
andlibxt_conntrack.so
I needed. Copy them to/usr/lib/iptables/
on your NAS, the 2 commands above should run without errors.And now
dockerd
should be able to start successfully with bridge network:Turn on IP Forwarding and Configure Firewall
To be able to communicate with your containers from your LAN, you also need to do these to allow IP forwarding:
And finally, open up your firewall to allow access to the ports. Assuming you have
-p 8080:80
for a container, you’ll need to open port8080
for your LAN the NAS is in (eg.192.168.0.0/24
).Configure a Proxy
With the above though, what I found was, if I ran a container with published ports, I still could only reach the server via
localhost
, but not via the LAN IP of my NAS.Docker was supposed to take care of this for me, but somehow it didn’t.
So I needed a proxy to forward packets (TCP in addition to HTTP/S, in my use case) between
192.168.0.10:8080
andlocalhost:8080
. I opted to usenginx
because I couldn’t get eitheriptables
ordocker-proxy
to work, but I had to change my LAN access to a new port, ie.192.168.0.10:8081
.Finally after also changing the open port in firewall to
8081
,curl 192.168.0.10:8081
worked.PS. If someone could tell me why
iptables
ordocker-proxy
didn’t forward ports betweenlocalhost
and my LAN IP, I’ll appreciate it.