php: docker-php-ext-install fails with phpize not finding config.m4
(I wrote a question on stackoverflow about it, but I guess it fits more here.)
My Dockerfile:
FROM php:5.6-apache
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
php -r "if (hash_file('SHA384', 'composer-setup.php') === '070854512ef404f16bac87071a6db9fd9721da1684cd4589b1196c3faf71b9a2682e2311b36a5079825e155ac7ce150d') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \
php composer-setup.php && \
php -r "unlink('composer-setup.php');"
RUN apt-get update && \
apt-get install vim git -y
RUN docker-php-ext-install mysqlnd pdo pdo_mysql
RUN cd / && \
git clone --depth=1 git://github.com/phalcon/cphalcon.git && \
cd cphalcon/build && \
./install
RUN echo "extension=phalcon.so" > /usr/local/etc/php/conf.d/phalcon.ini
RUN a2enmod rewrite
My docker-compose.yml:
phlaconapp:
hostname: phaclonapp
dockerfile: Dockerfile
build: ./
ports:
- "1080:80"
- "1043:433"
environment:
TERM: xterm-color
ENVIRONMENT: dev
volumes:
- ./:/var/www/html/
links:
- mysql
mysql:
image: mysql:5.6
volumes:
- ./docker/mysql.d:/etc/mysql/conf.d
ports: ["3306:3306"]
environment:
MYSQL_ROOT_PASSWORD: 'root'
Yet when running docker-compose build
I get:
\mysql uses an image, skipping
Building phlaconapp
Step 1 : FROM php:5.6-apache
---> 2dd2b6f11998
Step 2 : RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && php -r "if (hash_file('SHA384', 'composer-setup.php') === '070854512ef404f16bac87071a6db9fd9721da1684cd4589b1196c3faf71b9a2682e2311b36a5079825e155ac7ce150d') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && php composer-setup.php && php -r "unlink('composer-setup.php');"
---> Using cache
---> be0059709c8b
Step 3 : RUN apt-get update && apt-get install vim git -y
---> Using cache
---> 64cc739633c9
Step 4 : RUN docker-php-ext-install mysqlnd pdo pdo_mysql
---> Running in 8587aeb52c5b
+ cd /usr/src/php/ext/mysqlnd
+ phpize
Cannot find config.m4.
Make sure that you run '/usr/local/bin/phpize' in the top level source directory of the module
ERROR: Service 'phlaconapp' failed to build: The command '/bin/sh -c docker-php-ext-install mysqlnd pdo pdo_mysql' returned a non-zero code: 1
How am I supposed to install extension with docker-php-ext-install
?
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 7
- Comments: 21 (4 by maintainers)
Links to this issue
Commits related to this issue
- Workaround for https://github.com/docker-library/php/issues/233. — committed to weahead/docker-bedrock by michaellopez 8 years ago
- Workaround for https://github.com/docker-library/php/issues/233. — committed to weahead/docker-bedrock by michaellopez 8 years ago
- Workaround for https://github.com/docker-library/php/issues/233. — committed to weahead/docker-bedrock by michaellopez 8 years ago
- openssl already present in base image Linked to this issue https://github.com/docker-library/php/issues/233 — committed to nouchka/thelia by nouchka 7 years ago
- openssl already present in base image Linked to this issue https://github.com/docker-library/php/issues/233 — committed to Lucanis/thelia by nouchka 7 years ago
Another Quick-And-Dirty solution for “phpize, Cannot find config.m4.”:
#First we try to install your extension, it will fail here so force exit code 0 to keep Dockerfile processing. #We do this to have the extension files downloaded for step 2 RUN docker-php-ext-install zlib; exit 0 #Now we rename the in step 1 downloaded file to desired filename RUN cp /usr/src/php/ext/zlib/config0.m4 /usr/src/php/ext/zlib/config.m4 #And try to install extension again, this time it works RUN docker-php-ext-install zlib
Any ideas when this will be fixed? Still having this issue with latest
php:7.2-rc-fpm-alpine
.Removing the docker-php-ext-install zlib from the docker fixed for me
@chrBrd, openssl and a few other modules are built with php and do not require
docker-php-ext*
scripts: https://github.com/docker-library/php/blob/d8d798be28c49ced47d772aa899c0a1febabdba3/7.1/alpine3.4/fpm/Dockerfile#L116-L132You can even verify that it is available:
For me it failed couple times trying to install other extensions like zlib openssl, but these were already included in the base image when I ran phpinfo. Also I’m using @michaellopez workaround and it worked just fine. on
php:7.1.7-fpm-alpine
Dockerfile
My current workaround is not looking very nice:
Note that
apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS \
is needed after eachdocker-php-ext-install
call as that script removes the dependencies…Still affecting
php:7.4-fpm-alpine
but skipping installation of extensions that are already included in the image seems to avoid the issue.Still doesn’t work. sqlite3 has config0.m4 so phpize doesn’t manage to build the extension. How it supposed to work?
Removing
docker-php-ext-install zlib
fix the issue withphp:7.3-fpm-alpine
.If you take a look here, the extension is already installed.