1

I am always getting an error that PDO driver not found. I tried restarting, installing PDO extensions directly. Note that this docker setup works on my Linux box last night. Only difference is I did it from scratch compared to on my Windows box I already has images.

After getting the error initially I tried to remove the images, the base PHP image failed to remove for some reason. I then ran:

  1. docker exec -it php sh
  2. docker-php-ext-install pdo pdo_mysql

Running that command explains that the extensions were already installed. But I still receive the error.

I also noticed this is present along with the modules:

/var/www/html # ls /usr/local/etc/php/conf.d/                                
docker-php-ext-pdo_mysql.ini                                                 
/var/www/html # cat /usr/local/etc/php/conf.d/docker-php-ext-pdo_mysql.ini   
extension=pdo_mysql.so                                                       

DockerFile PHP

FROM php:7.1-fpm-alpine
RUN apk update \
   && docker-php-ext-install pdo pdo_mysql \
   && chown -R www-data:www-data /var/www/html \
   && sed -ri 's/^www-data:x:82:82:/www-data:x:1000:50:/' /etc/passwd

PHP Modules on Docker Container

PS C:> docker exec -it php sh      
/var/www/html # php -m                                                                 
[PHP Modules]                                                                          
Core                                                                                   
ctype                                                                                  
curl                                                                                   
date                                                                                   
dom                                                                                    
fileinfo                                                                               
filter                                                                                 
ftp                                                                                    
hash                                                                                    
iconv                                                                                  
json                                                                                   
libxml                                                                                 
mbstring                                                                               
mysqlnd                                                                                
openssl                                                                                
pcre                                                                                   
PDO                                                                                    
pdo_mysql                                                                              
pdo_sqlite                                                                             
Phar                                                                                   
posix                                                                                  
readline                                                                               
Reflection                                                                             
session                                                                                
SimpleXML                                                                               
SPL                                                                                    
sqlite3                                                                                
standard                                                                               
tokenizer                                                                              
xml                                                                                    
xmlreader                                                                              
xmlwriter                                                                              
zlib                                                                                                                                                                          
[Zend Modules]                                                                                                                                                                                                                                       

SysInfo

  • Windows 10 Pro
  • Docker version 17.06.0-ce, build 02c1d87
2
  • Try and remove the image, make sure that any containers based on this image are stopped and removed. Commented Jul 19, 2017 at 15:38
  • I did try that but still have an issue. As you can see the php modules are listed as installed. Commented Jul 19, 2017 at 16:02

2 Answers 2

2

I did use to see the already installed message when I ran docker build but it still built the image fine for me.

https://github.com/fire015/docker/blob/master/php-fpm-71/Dockerfile

Try building it from fresh using docker build --no-cache=true

Sign up to request clarification or add additional context in comments.

Comments

0

NONE of the above worked for me until I gave the image a tag when calling docker build and referenced that tag as the image in the docker-compose.yml file.

e.g.

PS C:\Users\Grrarth\dev\docker> docker build --no-cache=true .

FAILED where

PS C:\Users\Grrarth\dev\docker> docker build --no-cache=true -t MyImageName .

combined with the following (instead of using the standard image file name) in the docker-compose.yml file:

services:
  app:
    image: MyImageName
    ...

WORKS a treat.

I know it sounds obvious to experienced docker users but I have not seen anyone point it out for us newbies.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.