kodi + docker + nextcloud + mariadb => inter container communication issues

  • Hi,

    I'm very enthusiastic about installing Nextcloud as a Kodi plugin, that will define for me the systemd service. But I've to say that I'm more or less hopeless; after having tried initializing Nextcloud container and make it communicate with MariaDB.

    In sort

    I installed NextCloud and MariaDB addons, but when I connect to NextCloud UI for the install process (when we specify DB address, user and password), I got

    <br>

    Quote

    SQLSTATE[HY000] [2002] Connection refused





    Details

    I followed the steps detailed in this thread. Here are the detailed steps I followed:

    • install mariadb, with no user and pre-created db, or with a dedicated user and nc database (nc for NextCloud) as read in this thread

      • waiting for the installation to complete (cheching with docker logs that all installation steps finished and that the server is actually ready and listening)

      • in case I installed with a dedicated user:

        • checked that the user ('nextcloud'@'%') had all privileges by using mysql command in mariadb container
        • also checked the nextcloud password
    • install NextCloud addon

    • Wait for install to finish (checking container's logs)

    • reboot (I wonder why, but I tried ad it's mentioned by a moderator user in this comment, I did it without thinking)

    • checked that I'm able to access mariadb from another container:

      • installed Adminer image
      • added this container onto lsio network
      • successfully logged onto DB as root and nextcloud user (using 172.18.0.3, witch is MariaDB IP address in lsio network)
    • but when I try to connect MariaDB from Nextcloud, this just doesn't works:

      Code
      SQLSTATE[HY000] [2002] Connection refused

    I tried all combinations of:

    • using MariaDB root login / pass, or dedicated nc DB user / pass (that have all privileges on nc database)
    • using as DB host and port: all combinations of ("172.18.0.3", "mariadb") for host and ("3306", blank) for port

    Later I noticed that in NextCloud log file for every attempt there was this error:

    <br>

    Quote

    "remoteAddr":"192.168.1.45","user":"--","app":"no app in context","method":"POST","url":"/index.php","message":"Host 192.168.1.115 was not connected to because it violates local access rules","version":"20.0.6.1"


    I checked in Nextcloud's config.php file (/storage/.kodi/userdata/addon_data/docker.linuxserver.nextcloud/config/www/nextcloud/config/config.php) and my box LAN IP address is whitelisted in trusted domains:

    Code
    'trusted_domains' =>
    array (
        0 => '192.168.1.115',
    ),

    I also tested to add 'allow_local_remote_servers' => true, as I read here (without understanding deeply)

    Containers network problems


    When I launch bash on nextcloud container (docker exec -it nextcloud bash):

    • I'm not able to ping mariadb container
      • using its name mariadb
      • using its IP in lsio network (172.18.0.3 in my case)
    • I realized that I'm not able to access internet neither. Here's the content of /etc/resolv.conf:

      Code
      nameserver 127.0.0.11
      options ndots:0

    I suppose this isn't "normal", but I'm not an expert in networking.

    Final thoughts

    I'm wondering where did I missed something.

    • is the problem is related to the "local access rules violation" problem ?
    • is the problem is related to the communication issues between the 2 containers ? I'm on the verge to define my own docker-compose file and make a systemd service to see if that helps

    Additional information

    • LibreELEC v9.2.6 on Raspberry Pi4
    Code
    LibreELEC:~ # docker inspect -f '{{ index .Config.Labels "build_version" }}' mariadb
    Linuxserver.io version:- 110.4.17mariabionic-ls8 Build-date:- 2021-01-23T01:27:05-05:00
    LibreELEC:~ # docker inspect -f '{{ index .Config.Labels "build_version" }}' nextcloud
    Linuxserver.io version:- 20.0.6-ls117 Build-date:- 2021-01-26T13:30:45-05:00

    Does anyone have any clue ? aptalca maybe ? I'd be grateful !

    Thanks for reading !

  • Not being able to ping (and no internet) seems like the root issue, but no idea why that would be happening. The nameserver 127.0.0.11 seems correct as that is the internal docker resolver that should resolve mariadb to its container ip.


    I'll test it locally here and will let you know.

  • Not being able to ping (and no internet) seems like the root issue, but no idea why that would be happening. The nameserver 127.0.0.11 seems correct as that is the internal docker resolver that should resolve mariadb to its container ip.


    I'll test it locally here and will let you know.

    Thanks a lot ! I'm kind of stuck here :s
    By the way, what is the "root issue" ?

  • root issue = the main issue


    Just tested on my machine


    Installed the mariadb addon (if it starts with no data in its config folder, it pops open the settings for password entry)

    Entered a root password, along with a db name, user name and user password.

    Installed nextcloud, didn't change any settings.

    Waited for both to be started up and gave it another minute (watched the logs until services were ready for both)

    Then I accessed the nextcloud gui on port 443 (https), put in a user and password, selected mysql/mariadb, entered the db and user details and for address, entered "mariadb:3306". Also unchecked the box for installing recommended apps. It connected fine and was set up within a minute or so (may take a few minutes on slower hardware).


    When I exec into nextcloud, I can ping "mariadb" successfully:

    Code
    # docker exec -it nextcloud ping mariadb
    PING mariadb (172.19.0.2): 56 data bytes
    64 bytes from 172.19.0.2: seq=0 ttl=64 time=0.119 ms
    64 bytes from 172.19.0.2: seq=1 ttl=64 time=0.094 ms
    64 bytes from 172.19.0.2: seq=2 ttl=64 time=0.121 ms
    ^C
    --- mariadb ping statistics ---
    3 packets transmitted, 3 packets received, 0% packet loss
    round-trip min/avg/max = 0.094/0.111/0.121 ms


    The /etc/resolv.conf in nextcloud contains the following:

    Code
    # docker exec -it nextcloud cat /etc/resolv.conf
    search localdomain
    nameserver 127.0.0.11
    options ndots:0


    So really, out of the box, it should just work.

  • Thank a **lot** for testing, and for your detailed report ! I really appreciate this a lot.

    Indeed, the main issue seems to be the Docker networking issue. Even after manually editing `etc/resolv.conf` by hand I still can't ping mariadb. I suppose I now have to study Docker networking. Or trying the docker-compose alternative, I don't know yet.

    I'll let you informed here.

  • I just tried with a new SD card with a fresh LibreELEC v9.2.6 (LibreELEC-RPi4.arm-9.2.6.img) and ... It works !


    I suppose the problem I encountered is due to some addon maybe 🤔 Maybe VPN addon