Synology MariaDB 10 database connection

Hi,

Having started using Ignition at work I wanted to utilize my new found skills at home with a home automation setup on my Synology NAS using Ignition Maker.

Unfortunately I’m having trouble connecting Ignition to MariaDB 10 (both are installed on a Synology NAS). MariaDB is a Synology package and Ignition is in a Docker container. I’m able to access the database via phpMyAdmin (also a Synology package) but the database connection in Ignition is throwing an error.

I’ve tried resetting MariaDB’s password and granting full access to the user (‘root’ in this case).

Any help would be appreciated.

DB Error:

Cannot create PoolableConnectionFactory (Could not connect to address=(host=localhost)(port=3306)(type=master) : Socket fail to connect to host:localhost, port:3306. Connection refused (Connection refused))

Docker-compose settings:

Ignition DB settings:

phpMyAdmin:
image

Localhost in a container is not the host’s localhost. You’ll have to expose the MySQL instance on an IP address the container can reach.

1 Like

You could try using host.docker.internal instead of localhost in your DB configuration. That special name is supposed to resolve to the host systems IP from within a container on Docker Engine Docker Desktop.

UPDATE: That special hostname works automatically under Docker Desktop for Windows/macOS, but I realized (after searching for some documentation to provide) that it doesn’t work automatically under plain Docker Engine for Linux. However, it looks like you can add a host definition (see extra_hosts definition for Compose) to your Ignition service definition to get this functionality. See this link for more reference material on this topic: What is linux equivalent of "host.docker.internal" - Stack Overflow

Docker Run parameter: --add-host=host.docker.internal:host-gateway
Docker Compose extra_hosts addition:

    extra_hosts:
      - host.docker.internal:host-gateway
1 Like

Also, another note–your volume configuration in your compose spec looks to be invalid (and won’t cause any problems/warnings, it just won’t be persisting your data the way you expect). The right-hand side is the path within the container, and should be /usr/local/bin/ignition/data for the inductiveautomation/ignition image. When I’ve tried setting up Ignition under Docker on Synology, I’ve had to use a bind-mount configuration (this is with Docker installed as an “app” on DSM 6.2 on my DS1815+, not sure whether it is different on DSM7)… kcollins/ignition currently has some extra handling built-in for bind-mount configurations that don’t preload the target destination with existing files from the image on first-launch, so that might be worth a look (also the UID/GID functionality for bind-mounts can be handy wrt permissions).

1 Like

Thank you both for your replies. I’m new to Docker so it will take some time for me to digest all of the information you have given me.

I was able to get it working by adding 172.17.0.1 as the host gateway and also using that as the IP address in the DB connection settings.

Docker-compose:

extra_hosts:
- host.docker.internal:172.17.0.1

Ignition DB connection:

jdbc:mariadb://172.17.0.1:3306/‘my-database’

My next port of call was trying to get my configuration to be persistent and you have resolved that for me as well by noticing my volume config was wrong. Thanks for the help :slight_smile: