rolisz's site

Synology and Docker

After more than a year of using my NAS only to collect dust and the occasional backup, I decided this month to start self hosting various web apps on it. Synology has a visual Docker interface, so I installed that and I started trying to install my first app: Monica, which is a personal re­la­tion­ship manager (I love to track things).

Un­for­tu­nate­ly, modern technology has not yet solved this problem of deploying apps seamlessly. :(

Installing from the Docker registry

Installing Monica from the Docker registry

Installing the Monica Docker container was fairly simple: you search for it, click download, set the en­vi­ron­ment variables in the GUI, carefully copy pasting their names from the doc­u­men­ta­tion, and it kinda starts, but spews errors in the logs. Monica provides you with an example .env file, but you can't use it in the UI :(.

Setting the environment variables

Setting the en­vi­ron­ment variables

But then you get to the first problem: the database. Monica has a dependency on a MySQL database. It provides a docker compose file, which could bring it up and wire them together, but the Synology Docker UI doesn't have support for Docker Compos, so I had to manually provision the database.

Synology has a package for MariaDB. I tried to use that, but I couldn't figure out how to connect the two. Then I tried to install a MySQL Docker container, also from the UI. I struggled a lot to connect them, until I realized that the IP address that I had to pass was the one from the separate network Docker creates.

Once I got the database connection set up and ini­tial­ized, the app started, but it was working from an IP address. I wanted to add HTTPS support for it and I wanted to access it from a pretty url, so I had to add a DNS subdomain entry at my registrar.

I thought that I would have to open up a new port on my router to do all this, but it turns out that the Docker image for Monica serves only HTTP, so actually what you have to do is set up a reverse proxy to receive HTTPS requests from the outside world and send them on plain HTTP to your app. Luckily, Synology has a package built in for doing just this, inside Control Panel/Ap­pli­ca­tion Portal.

The last step was adding an SSL cer­tifi­cate from Let's Encrypt. Synology also has support for this, so it was trivial to do this, from the Control Panel/Security/Cer­tifi­cate.

I probably spent around two days figuring this out. Afterwards, the next apps were easier to install, but some still caused issues (like Wallabag). There are rumours of even better packaged solutions, but they don't have too many apps for now (also, why are torrenting/usenet apps so popular??).