0

So after trying many things it appears the app.docker file isn't running the RUN command correctly as the pdo driver isn't installed. How do I cure this?

I have a site in a docker-compose file. This was working fine until Docker updated today.

When I try and view the site in the browser (http://127.0.0.1:8080/) Laravel throws the error

Illuminate\Database\QueryException
could not find driver (SQL: select * from `CMSPages` where `PageSlug` = Homepage limit 1)
http://127.0.0.1:8080/ 

However, from the localhost I can run a migrate and seed and it connects with no issues. I can connect to the DB from heidi on the host as well, I have connected to the PHP instance, tried a php tinker and it also can connect to the DB and get data back.

So why can I not access the DB from the browser?

Docker-compose.yml

version: '2'

services:
    nginx:
      image: nginx:1.13.12
      ports:
        - "8443:443"
        - "8080:80"
      volumes:
        - ./:/var/www
        - ./docker/nginxconf:/etc/nginx/conf.d
        - ./docker/ssl-cert:/etc/nginx/certs
      working_dir: /var/www
      links:
        - php
    php:
        build:
            context: ./
            dockerfile: docker/app.docker
        volumes:
            - ./:/var/www
        depends_on:
          - db
        links:
            - db
        environment:
            - "DB_PORT=3306"
            - "DB_HOST=db"
    db:
        image: mariadb
        environment:
            - "MYSQL_ROOT_PASSWORD=removed"
            - "MYSQL_DATABASE=removed"
        ports:
            - "33061:3306"

app.docker

FROM php:7-fpm

RUN apt-get update
RUN apt-get install -y libmcrypt-dev mariadb-client
RUN apt-get install libmcrypt4
RUN docker-php-ext-install pdo_mysql

WORKDIR /var/www

Neo
  • 2,305
  • 4
  • 36
  • 70
  • Seems duplicate of https://stackoverflow.com/questions/42557693/laravel-pdoexception-could-not-find-driver – vodolaz095 Jan 22 '20 at 22:07
  • @vodolaz095 no, on that one they can't migrate I can without issues – Neo Jan 22 '20 at 22:11
  • Have you tried clearing your caches, restarting your webserver and restarting your db? – PtrTon Jan 22 '20 at 22:20
  • @PtrTon yep I've tried clearing route, config and cache – Neo Jan 22 '20 at 22:23
  • Have you confirmed your web application is loading your .env file correctly? – PtrTon Jan 22 '20 at 22:26
  • @PtrTon it must be otherwise doing a php artisan migrate wouldn't work? – Neo Jan 22 '20 at 22:26
  • Yeah on CLI it loads fine, but I'm worried that the application itself somehow does not have a config or an outdated config. You could create a route with `phpinfo()` on it to check. – PtrTon Jan 22 '20 at 22:28
  • @PtrTon I have done this, and while the ENV's are there, pdo_mysql isn't in the list even tho it is in the app.docker file. I've CLI'd onto it and ran the command to install it but still no joy – Neo Jan 22 '20 at 22:33
  • Oh you might have different php.ini files for cli and web. One does contain the extension while the other does not. – PtrTon Jan 22 '20 at 22:34
  • If I run the command kill -USR2 1 inside the php container after installing the pdo driver it all works! – Neo Jan 22 '20 at 22:40

0 Answers0