0
0

More than 1 year has passed since last update.

DockerのPostgres環境でDB接続エラー(could not find driver)

Posted at

エラー内容

Dockerで立ち上げたPHP+Postgresの環境で、PDOを利用してDB接続を行なったときに下記が発生

could not find driver

原因

DockerのphpコンテナにPDOドライバーがインストールされていないことが原因

対策

Dockerfileを使ってPDO(pdo_pgsql)をインストールして解決する
phpのDockerfileに下記を追加

RUN apt-get update && apt-get -y install libpq-dev
RUN docker-php-ext-install pdo_pgsql

注意点として、単にpdo_pgsqlをインストールしようとするとエラーが発生してしまうため、先にlibpq-devをインストールするのがポイント

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0