Php: Install PDO module

Created on 13 May 2018  路  5Comments  路  Source: docker-library/php

I'm trying to install a really basic php-apache container with the following dockerfile:
FROM php:7.0-apache RUN apt-get update \ && apt-get install -y docker-php-ext-install pdo pdo_mysql zip \
But I'm getting the following error:
@srv-ubn-services-1:/dockerdata/apache-php/test/html$ sudo docker build -t dockerfile .
Sending build context to Docker daemon 5.777MB
Step 1/2 : FROM php:7.0-apache
7.0-apache: Pulling from library/php
3d77ce4481b1: Already exists
32bfdb6043a8: Pull complete
327a3b8246c6: Pull complete
1e3b73e77223: Pull complete
a1d8f2630b58: Pull complete
5599b03aa14f: Pull complete
13b5cca3ce53: Pull complete
2946903117b3: Pull complete
5f4e5ea64a21: Pull complete
fb148e58f4f7: Pull complete
38d4c98f8633: Pull complete
3961f344711d: Pull complete
8c9c1bf3f7ae: Pull complete
47652e77dd72: Pull complete
Digest: sha256:a4714ba43781b2a63810a75f4937accf4195de59f11dbe6a3b297c446218c669
Status: Downloaded newer image for php:7.0-apache
---> 0eeaf7f569ff
Step 2/2 : RUN apt-get update && apt-get install -y docker-php-ext-install pdo pdo_mysql zip
---> Running in bec9f92b4d57
Get:1 http://security.debian.org jessie/updates InRelease [94.4 kB]
Ign http://deb.debian.org jessie InRelease
Get:2 http://deb.debian.org jessie-updates InRelease [145 kB]
Get:3 http://deb.debian.org jessie Release.gpg [2434 B]
Get:4 http://deb.debian.org jessie Release [148 kB]
Get:5 http://security.debian.org jessie/updates/main amd64 Packages [650 kB]
Get:6 http://deb.debian.org jessie-updates/main amd64 Packages [23.0 kB]
Get:7 http://deb.debian.org jessie/main amd64 Packages [9064 kB]
Fetched 10.1 MB in 9s (1073 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package docker-php-ext-install
E: Unable to locate package pdo
E: Unable to locate package pdo_mysql
The command '/bin/sh -c apt-get update && apt-get install -y docker-php-ext-install pdo pdo_mysql zip' returned a non-zero code: 100

Any hints on that?

question

Most helpful comment

Yes, PDO is, but the MySQL driver for PDO is not, so you need to
"docker-php-ext-install pdo_mysql".

All 5 comments

The packages you're trying to fetch from the debian repo aren't present. Are you looking for https://packages.debian.org/stretch/php-pdo-mysql

# apt search php | grep mysq

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

php-mdb2-driver-mysql/stable 1.5.0b4-2 all
php-mysql/stable 1:7.0+49 all
php7.0-mysql/stable,stable 7.0.27-0+deb9u1 amd64

For the docker-php-ext-install you're calling it as an argument for apt-get install when it's not a package.
https://github.com/docker-library/docs/tree/master/php#other-extensions

  1. PDO is already enabled in the php images
    console $ docker run -it --rm php:7.0-apache php -m [PHP Modules] Core ctype curl date dom fileinfo filter ftp hash iconv json libxml mbstring mysqlnd openssl pcre PDO pdo_sqlite Phar posix readline Reflection session SimpleXML SPL sqlite3 standard tokenizer xml xmlreader xmlwriter zlib
  2. to enable other modules you need to install their dependencies and then use docker-php-ext-install to install them; see the docs.
    dockerfile FROM php:7.0-apache RUN apt-get update && apt-get install -y \ libfreetype6-dev \ libjpeg62-turbo-dev \ libmcrypt-dev \ libpng-dev \ && docker-php-ext-install -j$(nproc) iconv mcrypt \ && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ && docker-php-ext-install -j$(nproc) gd

@yosifkit Are you shar that it's installed? Because if I call PDO I get an exception, that the driver was not found.

Yes, PDO is, but the MySQL driver for PDO is not, so you need to
"docker-php-ext-install pdo_mysql".

Can be closed, worked!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mcnesium picture mcnesium  路  3Comments

solocommand picture solocommand  路  3Comments

cordoval picture cordoval  路  3Comments

nojimage picture nojimage  路  3Comments

mikk150 picture mikk150  路  3Comments