0

Trying to run 'php artisan migrate' in docker returned following error

 Illuminate\Database\QueryException 

  could not find driver (SQL: select * from information_schema.tables where table_schema = admin and table_name = migrations and table_type = 'BASE TABLE')

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:678
    674▕         // If an exception occurs when attempting to run a query, we'll format the error
    675▕         // message to include the bindings with SQL, which will make this exception a
    676▕         // lot more helpful to the developer instead of just the database's errors.
    677▕         catch (Exception $e) {
  ➜ 678▕             throw new QueryException(
    679▕                 $query, $this->prepareBindings($bindings), $e
    680▕             );
    681▕         }
    682▕ 

      +33 vendor frames php-i`
  34  artisan:37
  Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

Found solution that I need to enable pdo_mysql which (I think) I did in my Dockerfile

FROM php:7.3

RUN apt-get update -y && apt-get install -y openssl zip unzip git
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN docker-php-ext-install pdo mbstring pdo_mysql


WORKDIR /app
COPY . .
RUN composer install

CMD php artisan serve --host=0.0.0.0
EXPOSE 8000

Also when I try to find php.ini file to simply uncomment pdo_mysql extension php-i is showing that there is no php.ini file

Loaded Configuration File => (none)
Kamil
  • 1
  • 1

1 Answers1

1

Seems that you don't have installed php-MySQL extension in your docker environment

RUN apt-get update \
&& apt-get -y --no-install-recommends install  php7.3-mysql php7.3-intl mysql-client php-common openssl zip unzip git \
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN docker-php-ext-install pdo mbstring pdo_mysql


WORKDIR /app
COPY . .
RUN composer install

CMD php artisan serve --host=0.0.0.0
EXPOSE 8000 
Michał G
  • 121
  • 2