Replacing my Raspberry Pi 2 with my Synology NAS and Docker

I recently moved my server from a 2012 Mac Mini to a Raspberry Pi 2, and while the Pi 2 has been doing a great job, another option recently became available to me.

I’ve been a long time user of Synology NAS products. Their products have great uptime, along with superior performance, mobile apps, file sharing etc.

I’ve been using them since 2001, and have only had a single unit fail on me.


I’ve considering using my NAS as my server several times, but until now it required you to install 3rd party software on your NAS, and most of the time the software would stop working when updating the operating system.

In their latest DSM software release they enabled Docker which is a lightweight virtualization technology.

I now have to option to create mini virtual machines with every service i run on my server, and deploy it to my NAS. The advantage to this approach is that each VM is isolated from the host system, and from the other VMs running.

In the screenshot below are some of the services i run, and the total memory consumption is slightly less than 200 MB, that’s how lightweight Docker is.

docker_img


To get my home surveillance (more on that later) service running i had to create a Dockerfile to build a VM image.

While it seemed a bit overwhelming at first, it turned out to be surprisingly easy.

Here’s an example file that just sets up a cronjob for copying RRD graphs from my surveillance to my web server.

FROM ubuntu:latest
MAINTAINER **********@gmail.com

RUN apt-get update && apt-get install -y openssh-client rsync

# Add crontab file in the cron directory
ADD crontab /etc/cron.d/sync_images
ADD ssh /root/.ssh
 
# Give execution rights on the cron job
RUN chmod 0644 /etc/cron.d/sync_images
RUN chmod -R 700 /root/.ssh
 
# Create the log file to be able to run tail
RUN touch /var/log/cron.log

VOLUME ["/data"] 
# Run the command on container startup
CMD cron && tail -f /var/log/cron.log

While it initially seems like more work, it is now highly portable. I can extract the VM container, move it to a (similar architecture) box, and deploy it, or i can just copy the Dockerfile to another box, and rebuild the image there.

The only downside to Docker that i’ve found so far, is that it’s not possible to build the images locally for a different architecture, meaning i have to build the images on my NAS.

Is it overkill for my needs ? certainly, but it was a lot of fun to setup, and that makes it all worth it.

comments powered by Disqus