
docker에서 'php artisan migration'을 실행하려고 하면 다음 오류가 반환되었습니다.
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))
Dockerfile에서 수행한 pdo_mysql을 활성화하는 데 필요한 솔루션을 찾았습니다.
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
또한 pdo_mysql 확장의 주석 처리를 제거하기 위해 php.ini 파일을 찾으려고 하면 php-i
php.ini 파일이 없다고 표시됩니다.
Loaded Configuration File => (none)
답변1
Docker 환경에 php-MySQL 확장을 설치하지 않은 것 같습니다.
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