Database Faulted even when I can connect

For our dev environment, we run Ignition in docker desktop on windows.
We also build the ignition image where the only changes we make is we also install ping, dig, mariadb-client, and git in the container.

When I exec into the container, I can connect to the database using the command mysql -u ignition -p -h db ignitiondb, where db is the docker-compose generated hostname for the service, and it does resolve correctly. I can connect when running that inside the container.

However, the database connection is faulted in the gateway. It seems to be faulting if its not set to a static IP. If it's set to a hostname such as db, or host.docker.internal, it fails, even though both resolve/connect properly in the container. If I set it to my windows LAN IP, it works, but that changes based on where I am.

Why would it be faulting if it's able to resolve and connect from in the container properly?

Is the database running as a container in a Compose stack? Or is it running on your host system? The reason I'm asking is because you mention it working when you set it to your Windows LAN IP, but elsewhere you seem to be implying that the DB is a container on the same Docker network.

Also, can you share the error in the log (from the FAULTED connection)? Perhaps your Compose YAML too?

Also, remember that if you're connecting from container to container, you're NOT using any published ports out to your host. For example, if it is MySQL/MariaDB, use port 3306 for your Ignition DB connection, even if you've published that port out to something else on your host.

That may be your issue (and would explain why it might work when pointed to your host system IP and trying to go through a published port).

It is container to container and they are in the same compose stack. And I'm not seeing anything being printed to the wrapper logs about failing to connect to the database (aside from irrelevant db operations complaining the db is faulted).

Mariadb container does print this one line occasionally though

2025-03-28 14:40:05 7 [Warning] Aborted connection 7 to db: 'ignitiondb' user: 'ignition' host: '172.18.0.1' (Got an error reading communication packets)

My docker compose file:

---
name: 'sfdev'  # If you didn't have this set previously, you will have to move data from old volumes to new volumes.


services:
  ignition:
    image: sfdev-ignition
    container_name: ignition
    restart: unless-stopped
    build: ${SF_PROJECT_DIR:-.}/ignition
    user: root
    environment:
      ACCEPT_IGNITION_EULA: 'Y'
      TZ: 'Etc/UTC'
      IGNITION_UID: '1000'
      IGNITION_GID: '1000'
      IGNITION_EDITION: 'standard'
      GATEWAY_MODULES_ENABLED: 'alarm-notification,perspective,reporting,tag-historian'
    depends_on:
      - db
      - py3
    command: >
      -n sfdev
      -m 4096
      -r /restore.gwbk
      --
      wrapper.java.initmemory=512
      -Dignition.projects.scanFrequency=3
      -Dignition.allowunsignedmodules=true
      -Dignition.http.client.manager.cookieSpec=standard
    volumes:
      - /data/ignition:/usr/local/bin/ignition/data
      - ./ssh:/home/ignition/.ssh
      - ${HOME}/.gitconfig:/home/ignition/.gitconfig
      - ${IGNITION_PROJECT_DIR}:/usr/local/bin/ignition/data/projects
      # Non-default modules are included in the Docker build file
      - ${SF_PROJECT_DIR:-.}/primers/ignition.gwbk:/restore.gwbk
    ports:
      - 8088:8088  # Gateway HTTP

  db:
    container_name: mariadb
    image: mariadb:11.6
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: 'redacted'
    ports:
      - '3306:3306'
    volumes:
      - /data/mariadb:/var/lib/mysql
      - ${SF_PROJECT_DIR:-.}/primers/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d

And dockerfile

FROM inductiveautomation/ignition:8.1.47
COPY modules/SerialForwarder-unsigned-2-0-1-b2022071313.modl /usr/local/bin/ignition/user-lib/modules/SerialForwarder.modl
COPY modules/twilio-3.1.45.modl /usr/local/bin/ignition/user-lib/modules/twilio.modl
COPY modules/mqtt-4.0.26.modl /usr/local/bin/ignition/user-lib/modules/mqtt.modl
COPY modules/Embr-Charts-2.0.0.modl /usr/local/bin/ignition/user-lib/modules/embr-charts.modl
COPY modules/MongoDB-Connector-module.modl /usr/local/bin/ignition/user-lib/modules/mongodb.modl

USER root

RUN apt-get update && \
    apt-get install -y \
      inetutils-ping \
      dnsutils \
      mariadb-client \
      git && \
    rm -rf /var/lib/apt/lists/*

USER ignition