Connecting Photoprism to MariaDB

hello everybody,

Bit of a newbie here. Trying to get up to speed on everything, but not easy. Searched a lot for this specific issues, havent found an answer so far.

Running Docker on a Mac mini (m1). Used this for Compose:

---
version: '2'
services:
  mariadb:
    image: mariadb
    container_name: mariadb
    restart: unless-stopped
    command: mysqld --transaction-isolation=READ-COMMITTED --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --max-connections=512 --innodb-rollback-on-timeout=OFF --innodb-lock-wait-timeout=50
    ports:
      - 3306:3306
    volumes:
      - "/Users/trial/photoprism/mariadb/storage:/var/lib/mysql"
    environment:
      MYSQL_ROOT_PASSWORD: passSQLRoot
      MYSQL_DATABASE: photoprism
      MYSQL_USER: photoprism
      MYSQL_PASSWORD: passPPword
    network_mode: bridge
      
  photoprism:
    image: photoprism/photoprism:latest
    container_name: photoprism
    ports:
      - 2342:2342
    environment:
      PHOTOPRISM_HTTP_PORT: 2342
      PHOTOPRISM_ADMIN_PASSWORD: "passWebMinword"                               
      PHOTOPRISM_DATABASE_DRIVER: "mysql"            
      PHOTOPRISM_DATABASE_SERVER: "mariadb:3306"     
      PHOTOPRISM_DATABASE_NAME: "photoprism"         
      PHOTOPRISM_DATABASE_USER: "photoprism"         
      PHOTOPRISM_DATABASE_PASSWORD: "passPPword"     
      PHOTOPRISM_SITE_URL: "http://localhost:2342/"  
      PHOTOPRISM_SITE_TITLE: "PhotoPrism"
      PHOTOPRISM_SITE_CAPTION: "Browse Your Life"
    volumes:
       - "/Users/trial/photoprism/import:/photoprism/import"
       - "/Users/trial/photoprism/storage:/photoprism/storage"
       - "/Users/trial/photoprism/photos:/photoprism/originals"
    restart: unless-stopped
    network_mode: bridge

Running this on Portainer (following some other tutorial).

When i run the stack, the containers are created successfully. MariaDB runs fine, but PhotoPrism doesnt.

when i view details, this is what i see:

level=info msg=“config: case-insensitive file system detected”
level=error msg=“dial tcp: lookup mariadb on 192.168.65.7:53: no such host”
level=info msg=“config: case-insensitive file system detected”
level=error msg=“dial tcp: lookup mariadb on 192.168.65.7:53: no such host”

This loop continues. seems to be Potoprism cant connect with MariaDB, they are running on the same stack … from what i am reading … they should be able to. Can somebody help pls.

It’s always safe to tie both of the containers to the same network.
Try this compose file:

version: '2'
services:
  mariadb:
    image: mariadb
    container_name: mariadb
    restart: unless-stopped
    command: mysqld --transaction-isolation=READ-COMMITTED --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --max-connections=512 --innodb-rollback-on-timeout=OFF --innodb-lock-wait-timeout=50
    ports:
      - 3306:3306
    volumes:
      - "/Users/trial/photoprism/mariadb/storage:/var/lib/mysql"
    environment:
      MYSQL_ROOT_PASSWORD: passSQLRoot
      MYSQL_DATABASE: photoprism
      MYSQL_USER: photoprism
      MYSQL_PASSWORD: passPPword
    networks:
      - net-bridge

  photoprism:
    image: photoprism/photoprism:latest
    container_name: photoprism
    ports:
      - 2342:2342
    environment:
      PHOTOPRISM_HTTP_PORT: 2342
      PHOTOPRISM_ADMIN_PASSWORD: "passWebMinword"
      PHOTOPRISM_DATABASE_DRIVER: "mysql"
      PHOTOPRISM_DATABASE_SERVER: "mariadb:3306"
      PHOTOPRISM_DATABASE_NAME: "photoprism"
      PHOTOPRISM_DATABASE_USER: "photoprism"
      PHOTOPRISM_DATABASE_PASSWORD: "passPPword"
      PHOTOPRISM_SITE_URL: "http://localhost:2342/"
      PHOTOPRISM_SITE_TITLE: "PhotoPrism"
      PHOTOPRISM_SITE_CAPTION: "Browse Your Life"
    volumes:
      - "/Users/trial/photoprism/import:/photoprism/import"
      - "/Users/trial/photoprism/storage:/photoprism/storage"
      - "/Users/trial/photoprism/photos:/photoprism/originals"
    restart: unless-stopped
    networks:
      - net-bridge

networks:
  net-bridge:

Just to provide a background on why it doesn’t work like the OP shared it:

This setting is the reason both containers couldn’t interact with each other:

It attaches the containers of both services to the default bridge network. The default bridge network does not support dns-based service discovery and requires container links instead. Though container links are a legacy feature, which eventually will be removed from the docker engine.

The proposed solution of @ajeetraina is the way to go!

Ajeet,

Thanks for the response. let me test it out and get back. appreciate the patience with a newbie.

rgds