Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Flatly)
  • No Skin
Collapse
Brand Logo

NetXMS Forum

  1. Home
  2. Development
  3. [Docker] Hardcoded pgsql in dbinit.sh and missing dbinit_mariadb.sql template

[Docker] Hardcoded pgsql in dbinit.sh and missing dbinit_mariadb.sql template

Scheduled Pinned Locked Moved Development
3 Posts 2 Posters 18.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C
    C
    cold
    wrote on last edited by
    #1

    I am deploying NetXMS via Docker using the official deployment-example/compose.yaml from netxms/docker (commit 55e823c), but replacing the built-in PostgreSQL container with an existing MariaDB instance.

    During the database initialization phase, I encountered two related issues:

    1. The server/files/dbinit.sh script has "pgsql" strictly hardcoded (nxdbmgr init pgsql), which forces PostgreSQL initialization regardless of the DBDriver configured in /etc/netxmsd.conf or environment variables.

    2. If we manually override /dbinit.sh on init container to initialize MariaDB (nxdbmgr init mariadb), the process fails because nxdbmgr looks for a specific dbinit_mariadb.sql file in a directory that does not exist in the Docker image.

    Environment:

    • NetXMS Version: 6.1.1 (Build 6.1-452-gc20a8a4247)
    • Deployment: Docker (using official deployment-example/compose.yaml)
    • Database: MariaDB 10.11

    Steps to Reproduce:

    1. Setup the deployment using the example compose.yml file, pointing /etc/netxmsd.conf to a MariaDB database (DBDriver = mariadb.ddr).
    2. Override /dbinit.sh (entrypoint) on init container via bind mount to execute nxdbmgr init mariadb.
    3. Start the init container.

    Error Log (when using mariadb driver for init):

    NetXMS Database Manager Version 6.1.1 Build 6.1-452-gc20a8a4247
    Initializing database...
    ERROR: Cannot load SQL command file /usr/share/netxms/sql/dbinit_mariadb.sql
    Database initialization failed
    Unable to determine database syntax
    

    Note: I verified inside the container that the directory /usr/share/netxms does not exist on the NetXMS Server Docker image.

    If I change the /etc/netxmsd.conf  to use mysql instead (nxdbmgr init mysql), the database initializes perfectly, even though I am using a MariaDB container:

    NetXMS Database Manager Version 6.1.1 Build 6.1-452-gc20a8a4247
    Initializing database...
    IMPORTANT: Generated admin password
       Login:    admin
       Password: PaSsWd
    Please save this password - it will not be shown again.
    You will be required to change it on first login.
    Database initialized successfully
    

    Suggested Fixes:

    1. Dynamic Driver Selection: Update /dbinit.sh to dynamically read the database driver from a Docker environment variable (e.g., NETXMS_DB_DRIVER) or directly from /etc/netxmsd.conf, falling back to pgsql only if nothing is set. Changing nxdbmgr init pgsql to simply nxdbmgr init allows the utility to dynamically deduce the driver from /etc/netxmsd.conf, as intended by the documentation.
    2. Template Mapping: Either include the dbinit_mariadb.sql template in the image build process or alias the mariadb initialization argument to use the mysql SQL template internally, since the schema structure is identical.
    1 Reply Last reply
    0
    • A
      A
      Alex Kirhenshtein
      wrote on last edited by
      #2

      Hi cold,

      Thanks for the report. This has been fixed in commit 4e26775.

      The dbinit.sh script now auto-detects the database driver from the DBDriver setting in netxmsd.conf instead of hardcoding pgsql. If you set DBDriver=mariadb (or mysql) in your netxmsd.conf, the initialization will work automatically.

      For the second issue — the missing dbinit_mariadb.sql — this is expected behavior. NetXMS uses "mysql" as the umbrella driver name for both MySQL and MariaDB SQL templates. So you should use DBDriver=mariadb in your config (the driver itself handles the connection correctly), but the schema initialization template is shared. With this fix, nxdbmgr init auto-selects the correct template, so you don't need to worry about it.

      As a bonus, the fix also adds support for TimescaleDB initialization via the NETXMS_PG_TYPE environment variable (set NETXMS_PG_TYPE=tsdb on the init service).

      The fix will be included in the next Docker image release (already in :latest).

      1 Reply Last reply
      0
      • C
        C
        cold
        wrote on last edited by
        #3

        Hello Alex!
        Thank you for your fast reply.
        The documentation states that there is a specific MariaDB driver and the “netxms-dbdrv-mariadb” package for Debian: https://www.netxms.org/documentation/adminguide/installation.html#mariadb
        So it didn’t exist on the Docker image, and I should use MySQL instead even after DB init? Because DB initialization still fails when using MariaDB as DBDriver on Docker, I think there's some issue where the code is not sharing the same code init template with MySQL for some reason.
        Edit: My bad, the fix works as expected; there is a PR that improves the error handling at: https://github.com/netxms/docker/pull/3

        1 Reply Last reply
        0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        Powered by NodeBB Contributors
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups