0

I've installed linuxserver nginx as a docker container. Which contains PHP. tested, and all works as expected eg can serve PHP pages etc. I've tried to add mariadb as a service to the same stack. The container 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."

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
Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
PHP Addict
  • 71
  • 1
  • 9
  • Are the double quotes in the `mariadb` `environment:` section causing problems; are you getting a database named `"Jack Daniels"` including the double quotes? If you put double quotes in the middle of a YAML string it inserts quote characters and does not cause quoting behavior; you don't actually need any quoting with this particular syntax. – David Maze Jun 16 '23 at 14:22
  • Hi David, I've tried both ways with and without quotes. Still the same problem. However I'll remember that. Thanks – PHP Addict Jun 16 '23 at 14:25

0 Answers0