Setting up Rancher on Synology


I am guessing you came here because you are looking for information about Docker, Rancher and Synology.

In case one or more of these terms are unfamiliar, here is a quick summary. Synology is a company that builds storage servers for both home and professional use, Docker is a software containerization platform and Rancher is an open source platform for managing your Docker environment.


Preparing the Synology

You will need to install the Docker package on your Synology. If your model supports it it will be available in the Package Center out of the box, as it is an official package.

Further on, you will want ssh access to your Synology as you will need to modify your web server config to proxy web traffic to your containers.


This assumes you are running nginx on your Synology, if you are using apache instead the configuration is slightly different. However, the same setup can be achieved.

SSH your Synology and create a file called /etc/nginx/sites-enabled/proxy.conf

# Direct traffic to to the rancher/server container.
server {  
    listen 80;
    location / {
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real_IP $remote_addr;

# Direct traffic to certain subdomains to rancher's load balancer.
server {  
    listen          80;
    location / {
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;

Restart nginx

synoservicectl --restart nginx


docker run -d --restart=unless-stopped -p 8080:8080 rancher/server  


Ensure the log directory exists, docker won't create this on its own for some reason.

mkdir /var/log/rancher  

After you head into your rancher installation, go to Hosts and Add host. Then setup rancher to use for incoming agent connections.

Then, copy the docker run command that rancher generates for your new host. It looks something like this:

sudo docker run -d --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.0.2  

For the agent to work on Synology, you need to modify it slightly. The docker.sock volume is found in /run/docker.sock and you need to mount a share into /var/lib/docker in the container. I am using /volume1/docker/rancher in this example.

The resulting docker run command should look something like this:

docker run -d --privileged -v /run/docker.sock:/var/run/docker.sock -v /volume1/docker/rancher:/var/lib/rancher rancher/agent:v1.0.2  

After you run it, wait for a couple of minutes and watch it show up in your Rancher.

comments powered by Disqus