Docker install on qnap nas

Hi,

I am trying to get Emoncms installed on my Qnap Nas.

I could not get the docker compose file to work on the Qnap so I went ahead and created the containers for MySQL and Emoncms manually.

MySQL is installed and works when I connect to it from my PC db client.

I have manually created an Emoncms user with full permissions to create tables and have also created an Emoncms database schema.

I created a container from the Emoncms latest image and can run it up supplying all the environment options for MySQL, redis, mqtt etc.

When I start up the container and hit port 80 it returns an error message saying that the php fails on getaddrinfo for the database.

I am new to docker and I don’t know how php works either so I do not know how to diagnose this connectivity issue.

Can anyone provide any pointers on what configuration I can change to get the two containers to talk to each other?

The mysql-host property of the Emoncms container is set to the DNS name of my Nas and the mysql-port is set to the host port of the Nas that is mapped to the MySQL container port.

Any suggestions would be greatly appreciated.

So I got a bit further with the install.

Using ip addresses rather than DNS names fixed the issue of connectivity, there is a setting within the Qnap docker settings for Nat container but I did not try changing it.

The next issue was with file permissions for the www-data user of the Emoncms container.

Using the terminal of the container I used chown to fix that.

So that got the container up and running with a MySQL backend.

So some more learnings if you are wanting to install on a Qnap NAS.

You must install a redis container, I used the docker one and am having no issues.

I noticed a suggestion at the beginning of this page: emoncms/readme.md at master · emoncms/emoncms · GitHub

Although it only suggests Redis is used, from experience it would appear it is essential for operation. Since turning it on I have found significant improvements not just in bulk uploads but in the html response times as well.

There are no config options for redis docker image, simply map a host port to 6379 on the container and configure the emoncms docker image to use it and off you go.

Personally, I’ve put everything in a LXC container.
I find it far more easy to manage at the end. You can also manage volumes to store data outside the container.

On hindsight I think an lxc container for Emoncms would be have been more suitable.

The reason for going docker was to make it easier for less experienced people to bring up am Emoncms on a home Nas, ie all point and click with no command line or ssh.

If you do not use phpfina or phptimeseries feeds and store everything in MySQL then it is possible to achieve a point and click approach just using the Qnap UI.

The downside of using docker containers on Qnap, which is the first time I have tried it, is that there is no way to modify an environment variable without creating a new container.

You can’t just stop a container, change a variable and start it up again, you have to totally rebuild the container.

For an Emoncms container with 20+ variables, that is a lot of clicking and typing (or cut and pasting as I ended up doing). Docker containers in Qnap are painful to work with if you are used to the command line.

Now I have hit upon the secret sauce of required components my home Emoncms has been up for about a week and has now received a months worth of history from an Iotawatt.

All I have to do now is get data from a Fronius inverter uploaded as well.

Given how quickly I was up and running with pvoutput which supports both iotawatt and Fronius out of the box, going to the effort required for Emoncms on Qnap would make me recommend pvoutput over onsite hosting for most people just on the convenience alone unless you really want to keep your data off the internet.