Fresh install of nginx and mariadb unable to query db

Hey, my first post! so please be nice.
I’ve just started to get in to docker and containers! yes I know…

I installed nginx package from L.IO and it worked straight of the box with php etc.
I then added the l.io mariadb package to the same stack

The containers runs fine. However when trying to query the db from a page I get a 500 error “192.168.1.109 can’t
currently handle this request.”
Can anyone shed some light on what I’m doing wrong?

DB query is:
$pdo = new PDO(‘mysql:dbname=Jack Daniels;host=mysql’, ‘test_db’, ‘My_Pwd’, [PDO::ATTR_ERRMODE => PDO::ERRMODE_ALL]);

$query = $pdo->query(‘SHOW VARIABLES like “version”’);

$row = $query->fetch();

echo ‘MySQL version:’ . $row[‘Value’];

My composer yaml file is as follows:

version: "2.1"
services:
  nginx:
    image: lscr.io/linuxserver/nginx:latest
    container_name: nginx
    environment:
      - PUID=1029
      - PGID=100
      - TZ=Etc/GMT
    volumes:
      - /volume1/docker/database:/config

    ports:
      - 8110:80
      - 8114:443
    restart: unless-stopped


  mariadb:
    image: lscr.io/linuxserver/mariadb:latest
    container_name: mariadb
    environment:
      - PUID=1029
      - PGID=100
      - TZ=Etc/GMT
      - MYSQL_ROOT_PASSWORD=ROOT_ACCESS_PASSWORD
      - MYSQL_DATABASE=test_db
      - MYSQL_USER=Jack Daniels
      - MYSQL_PASSWORD=My_Pwd
      #- REMOTE_SQL=http://URL1/your.sql,https://URL2/your.sql #optional
    volumes:
      - /volume1/docker/database:/config
    ports:
      - 3306:3306

    restart: unless-stopped

this part is wrong to start, you’ve named your container mariadb, not mysql, to the host should be mariadb. Beyond that, you would want to login directly and confirm you can login and that you see the test_db when you do show databases;

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.