New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better support/documentation for docker-php-ext-install? #75

Closed
MrTrick opened this Issue Mar 17, 2015 · 37 comments

Comments

Projects
None yet
@MrTrick

MrTrick commented Mar 17, 2015

I'm having trouble running docker-php-ext-install ldap - what are that module's dependencies?
Searching for ldap.h in the ubuntu packages website led me to install libldap2-dev but there are still outstanding issues; configure: error: Cannot find ldap libraries in /usr/lib.

The meta-problem: How do users know what the dependencies are?
The php image is from a fixed platform, and there are relatively few extensions.
An automatic mechanism to grab those dependencies and provide working config defaults, or even just some documentation for each extension, would go a long way towards ease-of-use.

@MrTrick

This comment has been minimized.

Show comment
Hide comment
@MrTrick

MrTrick Mar 17, 2015

After trawling through /usr/src/php/ext/ldap/configure and tracing back from the error message, I eventually figured out that the LDAP extension can be installed with the following commands;

 # Install needed php extensions: ldap
RUN \
    apt-get update && \
    apt-get install libldap2-dev -y && \
    rm -rf /var/lib/apt/lists/* && \
    docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ && \
    docker-php-ext-install ldap

Leaving this issue open because I think the wider problem is still relevant.

MrTrick commented Mar 17, 2015

After trawling through /usr/src/php/ext/ldap/configure and tracing back from the error message, I eventually figured out that the LDAP extension can be installed with the following commands;

 # Install needed php extensions: ldap
RUN \
    apt-get update && \
    apt-get install libldap2-dev -y && \
    rm -rf /var/lib/apt/lists/* && \
    docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ && \
    docker-php-ext-install ldap

Leaving this issue open because I think the wider problem is still relevant.

@cg-d

This comment has been minimized.

Show comment
Hide comment
@cg-d

cg-d Aug 17, 2015

I had an analogous problem when trying to install soap. I had extend my Dockerfile with

apt-get install -y libxml2-dev --no-install-recommends

I did not test yet whether installing one or some of ext-install options xml, xmlreader, xmlrpc, xmlwriter, or xsl would do the trick. And if so in which order?

cg-d commented Aug 17, 2015

I had an analogous problem when trying to install soap. I had extend my Dockerfile with

apt-get install -y libxml2-dev --no-install-recommends

I did not test yet whether installing one or some of ext-install options xml, xmlreader, xmlrpc, xmlwriter, or xsl would do the trick. And if so in which order?

@jmkgreen

This comment has been minimized.

Show comment
Hide comment
@jmkgreen

jmkgreen Sep 3, 2015

+1 for @MrTrick comment - finally built with LDAP now.

jmkgreen commented Sep 3, 2015

+1 for @MrTrick comment - finally built with LDAP now.

@devurandom

This comment has been minimized.

Show comment
Hide comment
@devurandom

devurandom Sep 8, 2015

I agree with the original poster that docker-php-ext-install should by default do the installation of dependencies and the correct configure options automatically. I am not a PHP maintainer / packager. I have no idea what dependencies each extension has. I can peek into the Debian package database or into the Gentoo ebuild, but that is not really convenient.

I suggest that the docker image includes a file which maps extensions to their dependencies (Debian package names) and possibly the required configure flags. The docker-php-ext-install could use that information to automatically install and configure. For users who want more control you could add a --manual flag, which disables that and just does what the script does currently.

ATM the added value above the Debian provided PHP packages seems very small (unless you need a very specific version of PHP, which I don't).

devurandom commented Sep 8, 2015

I agree with the original poster that docker-php-ext-install should by default do the installation of dependencies and the correct configure options automatically. I am not a PHP maintainer / packager. I have no idea what dependencies each extension has. I can peek into the Debian package database or into the Gentoo ebuild, but that is not really convenient.

I suggest that the docker image includes a file which maps extensions to their dependencies (Debian package names) and possibly the required configure flags. The docker-php-ext-install could use that information to automatically install and configure. For users who want more control you could add a --manual flag, which disables that and just does what the script does currently.

ATM the added value above the Debian provided PHP packages seems very small (unless you need a very specific version of PHP, which I don't).

@yosifkit

This comment has been minimized.

Show comment
Hide comment
@yosifkit

yosifkit Sep 8, 2015

Member

Most likely, if this route is feasibly maintainable, it should also automatically remove debian packages it installed that were only required to make the module, but not needed for runtime. Ensuring that dynamically linked libraries are kept. Then it also has to assume to do an apt-get update and rm -rf /var/lib/apt/lists/* in order to not affect the layer size excessively.

Member

yosifkit commented Sep 8, 2015

Most likely, if this route is feasibly maintainable, it should also automatically remove debian packages it installed that were only required to make the module, but not needed for runtime. Ensuring that dynamically linked libraries are kept. Then it also has to assume to do an apt-get update and rm -rf /var/lib/apt/lists/* in order to not affect the layer size excessively.

@carnage

This comment has been minimized.

Show comment
Hide comment
@carnage

carnage Nov 6, 2015

(Incomplete) List of extensions and the debian packages they require to build:

ldap: libldap2-dev (configure: --with-libdir=lib/x86_64-linux-gnu/)
soap: libxml2-dev
mcrypt: libmcrypt-dev
ftp: libssl-dev
intl: libicu-dev
xsl: libxslt-dev
imap: libc-client-dev libkrb5-dev (configure: --with-kerberos --with-imap-ssl)

carnage commented Nov 6, 2015

(Incomplete) List of extensions and the debian packages they require to build:

ldap: libldap2-dev (configure: --with-libdir=lib/x86_64-linux-gnu/)
soap: libxml2-dev
mcrypt: libmcrypt-dev
ftp: libssl-dev
intl: libicu-dev
xsl: libxslt-dev
imap: libc-client-dev libkrb5-dev (configure: --with-kerberos --with-imap-ssl)

@schmunk42

This comment has been minimized.

Show comment
Hide comment
@schmunk42

schmunk42 Jan 29, 2016

@yosifkit The list from @carnage contains very useful information, it should be reference from the README https://github.com/docker-library/docs/tree/master/php or added to it.

Where should the place for it in the docs?

schmunk42 commented Jan 29, 2016

@yosifkit The list from @carnage contains very useful information, it should be reference from the README https://github.com/docker-library/docs/tree/master/php or added to it.

Where should the place for it in the docs?

@ghost ghost referenced this issue Apr 7, 2016

Closed

uopz extension #217

@urzds

This comment has been minimized.

Show comment
Hide comment
@urzds

urzds Apr 14, 2016

@carnage That list should definitely become part of this repository. It's very useful and could in the future be use to automate this.

Further, php-ext-install could also handle the cleanup (i.e. the cleanup section for the binary, just for extensions).

urzds commented Apr 14, 2016

@carnage That list should definitely become part of this repository. It's very useful and could in the future be use to automate this.

Further, php-ext-install could also handle the cleanup (i.e. the cleanup section for the binary, just for extensions).

@mmeuser

This comment has been minimized.

Show comment
Hide comment
@mmeuser

mmeuser Apr 19, 2016

+1 had the same problem and MrTrick's comment helped, thx

mmeuser commented Apr 19, 2016

+1 had the same problem and MrTrick's comment helped, thx

@schmunk42

This comment has been minimized.

Show comment
Hide comment
@schmunk42

schmunk42 Apr 19, 2016

You can get at least some hints from apt-cache which packages are needed for building an extension.
I've just created a debian-based image for that, improvements/ideas welcome...

Examples:

$ docker run schmunk42/apt apt-cache depends php5-xsl   
php5-xsl
  Depends: libc6
  Depends: libxml2
  Depends: libxslt1.1
  Depends: <phpapi-20131226>
    php5-common
  Depends: php5-common
  Depends: ucf
$ docker run schmunk42/apt apt-cache depends php5-ldap
php5-ldap
  Depends: libc6
  Depends: libldap-2.4-2
  Depends: libsasl2-2
  Depends: <phpapi-20131226>
    php5-common
  Depends: php5-common
  Depends: ucf

schmunk42 commented Apr 19, 2016

You can get at least some hints from apt-cache which packages are needed for building an extension.
I've just created a debian-based image for that, improvements/ideas welcome...

Examples:

$ docker run schmunk42/apt apt-cache depends php5-xsl   
php5-xsl
  Depends: libc6
  Depends: libxml2
  Depends: libxslt1.1
  Depends: <phpapi-20131226>
    php5-common
  Depends: php5-common
  Depends: ucf
$ docker run schmunk42/apt apt-cache depends php5-ldap
php5-ldap
  Depends: libc6
  Depends: libldap-2.4-2
  Depends: libsasl2-2
  Depends: <phpapi-20131226>
    php5-common
  Depends: php5-common
  Depends: ucf
@hp9390

This comment has been minimized.

Show comment
Hide comment
@hp9390

hp9390 Jul 28, 2016

An almost complete list:

RUN apt update
RUN apt upgrade -y
RUN apt install -y apt-utils
RUN a2enmod rewrite
RUN apt install -y libmcrypt-dev
RUN docker-php-ext-install mcrypt
RUN apt install -y libicu-dev
RUN docker-php-ext-install -j$(nproc) intl
RUN apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng12-dev
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ 
RUN docker-php-ext-install -j$(nproc) gd    
RUN apt install -y php-apc    
RUN apt install -y libxml2-dev 
RUN apt install -y libldb-dev
RUN apt install -y libldap2-dev 
RUN apt install -y libxml2-dev
RUN apt install -y libssl-dev
RUN apt install -y libxslt-dev
RUN apt install -y libpq-dev
RUN apt install -y postgresql-client
RUN apt install -y mysql-client 
RUN apt install -y libsqlite3-dev
RUN apt install -y libsqlite3-0
RUN apt install -y libc-client-dev
RUN apt install -y libkrb5-dev
RUN apt install -y curl
RUN apt install -y libcurl3
RUN apt install -y libcurl3-dev
RUN apt install -y firebird-dev
RUN apt-get install -y libpspell-dev
RUN apt-get install -y aspell-en
RUN apt-get install -y aspell-de  
RUN apt install -y libtidy-dev
RUN apt install -y libsnmp-dev
RUN apt install -y librecode0
RUN apt install -y librecode-dev
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer
#RUN pecl install apc
RUN docker-php-ext-install opcache
RUN yes | pecl install xdebug \
    && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini
RUN docker-php-ext-install soap
RUN docker-php-ext-install ftp
RUN docker-php-ext-install xsl
RUN docker-php-ext-install bcmath
RUN docker-php-ext-install calendar
RUN docker-php-ext-install ctype
RUN docker-php-ext-install dba
RUN docker-php-ext-install dom
RUN docker-php-ext-install zip
RUN docker-php-ext-install session
RUN docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu
RUN docker-php-ext-install ldap
RUN docker-php-ext-install json
RUN docker-php-ext-install hash
RUN docker-php-ext-install sockets
RUN docker-php-ext-install pdo
RUN docker-php-ext-install mbstring
RUN docker-php-ext-install tokenizer
RUN docker-php-ext-install pgsql
RUN docker-php-ext-install pdo_pgsql
RUN docker-php-ext-install pdo_mysql 
RUN docker-php-ext-install pdo_sqlite
RUN docker-php-ext-install intl
RUN docker-php-ext-install mcrypt
RUN docker-php-ext-install mysqli
RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl
RUN docker-php-ext-install imap
RUN docker-php-ext-install gd
RUN docker-php-ext-install curl
RUN docker-php-ext-install exif
RUN docker-php-ext-install fileinfo
RUN docker-php-ext-install gettext
#RUN apt install -y libgmp-dev # idk
#RUN docker-php-ext-install gmp # idk
RUN docker-php-ext-install iconv
RUN docker-php-ext-install interbase
RUN docker-php-ext-install pdo_firebird
RUN docker-php-ext-install opcache
#RUN docker-php-ext-install oci8 # idk
#RUN docker-php-ext-install odbc # idk
RUN docker-php-ext-install pcntl
#RUN apt install -y freetds-dev # idk
#RUN docker-php-ext-install pdo_dblib  # idk
#RUN docker-php-ext-install pdo_oci # idk
#RUN docker-php-ext-install pdo_odbc # idk
RUN docker-php-ext-install phar
RUN docker-php-ext-install posix
RUN docker-php-ext-install pspell
#RUN apt install -y libreadline-dev # idk
#RUN docker-php-ext-install readline # idk
RUN docker-php-ext-install recode
RUN docker-php-ext-install shmop
RUN docker-php-ext-install simplexml
RUN docker-php-ext-install snmp
RUN docker-php-ext-install sysvmsg
RUN docker-php-ext-install sysvsem
RUN docker-php-ext-install sysvshm
RUN docker-php-ext-install tidy
RUN docker-php-ext-install wddx
RUN docker-php-ext-install xml
#RUN apt install -y libxml2-dev # idk
#RUN docker-php-ext-install xmlreader # idk
RUN docker-php-ext-install xmlrpc
RUN docker-php-ext-install xmlwriter             
# idk bz2 enchant 

Off topic, but another tip:

If you, like me, need to run ie a framework and want to access your source directory from within your host system (lets say in your IDE for dev purposes), add this in your Dockerfile:
RUN useradd user
Then, you will need to add a config file for your Apache. My preferred way of doing this is mounting it. Anyway, the directory is /etc/apache2/conf-enabled.
In your config you need to add:

User user
Group user

Of course, you will need to replace user with your local user.

Maybe someone can figure out a way to make those missing extensions work.

hp9390 commented Jul 28, 2016

An almost complete list:

RUN apt update
RUN apt upgrade -y
RUN apt install -y apt-utils
RUN a2enmod rewrite
RUN apt install -y libmcrypt-dev
RUN docker-php-ext-install mcrypt
RUN apt install -y libicu-dev
RUN docker-php-ext-install -j$(nproc) intl
RUN apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng12-dev
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ 
RUN docker-php-ext-install -j$(nproc) gd    
RUN apt install -y php-apc    
RUN apt install -y libxml2-dev 
RUN apt install -y libldb-dev
RUN apt install -y libldap2-dev 
RUN apt install -y libxml2-dev
RUN apt install -y libssl-dev
RUN apt install -y libxslt-dev
RUN apt install -y libpq-dev
RUN apt install -y postgresql-client
RUN apt install -y mysql-client 
RUN apt install -y libsqlite3-dev
RUN apt install -y libsqlite3-0
RUN apt install -y libc-client-dev
RUN apt install -y libkrb5-dev
RUN apt install -y curl
RUN apt install -y libcurl3
RUN apt install -y libcurl3-dev
RUN apt install -y firebird-dev
RUN apt-get install -y libpspell-dev
RUN apt-get install -y aspell-en
RUN apt-get install -y aspell-de  
RUN apt install -y libtidy-dev
RUN apt install -y libsnmp-dev
RUN apt install -y librecode0
RUN apt install -y librecode-dev
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer
#RUN pecl install apc
RUN docker-php-ext-install opcache
RUN yes | pecl install xdebug \
    && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini
RUN docker-php-ext-install soap
RUN docker-php-ext-install ftp
RUN docker-php-ext-install xsl
RUN docker-php-ext-install bcmath
RUN docker-php-ext-install calendar
RUN docker-php-ext-install ctype
RUN docker-php-ext-install dba
RUN docker-php-ext-install dom
RUN docker-php-ext-install zip
RUN docker-php-ext-install session
RUN docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu
RUN docker-php-ext-install ldap
RUN docker-php-ext-install json
RUN docker-php-ext-install hash
RUN docker-php-ext-install sockets
RUN docker-php-ext-install pdo
RUN docker-php-ext-install mbstring
RUN docker-php-ext-install tokenizer
RUN docker-php-ext-install pgsql
RUN docker-php-ext-install pdo_pgsql
RUN docker-php-ext-install pdo_mysql 
RUN docker-php-ext-install pdo_sqlite
RUN docker-php-ext-install intl
RUN docker-php-ext-install mcrypt
RUN docker-php-ext-install mysqli
RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl
RUN docker-php-ext-install imap
RUN docker-php-ext-install gd
RUN docker-php-ext-install curl
RUN docker-php-ext-install exif
RUN docker-php-ext-install fileinfo
RUN docker-php-ext-install gettext
#RUN apt install -y libgmp-dev # idk
#RUN docker-php-ext-install gmp # idk
RUN docker-php-ext-install iconv
RUN docker-php-ext-install interbase
RUN docker-php-ext-install pdo_firebird
RUN docker-php-ext-install opcache
#RUN docker-php-ext-install oci8 # idk
#RUN docker-php-ext-install odbc # idk
RUN docker-php-ext-install pcntl
#RUN apt install -y freetds-dev # idk
#RUN docker-php-ext-install pdo_dblib  # idk
#RUN docker-php-ext-install pdo_oci # idk
#RUN docker-php-ext-install pdo_odbc # idk
RUN docker-php-ext-install phar
RUN docker-php-ext-install posix
RUN docker-php-ext-install pspell
#RUN apt install -y libreadline-dev # idk
#RUN docker-php-ext-install readline # idk
RUN docker-php-ext-install recode
RUN docker-php-ext-install shmop
RUN docker-php-ext-install simplexml
RUN docker-php-ext-install snmp
RUN docker-php-ext-install sysvmsg
RUN docker-php-ext-install sysvsem
RUN docker-php-ext-install sysvshm
RUN docker-php-ext-install tidy
RUN docker-php-ext-install wddx
RUN docker-php-ext-install xml
#RUN apt install -y libxml2-dev # idk
#RUN docker-php-ext-install xmlreader # idk
RUN docker-php-ext-install xmlrpc
RUN docker-php-ext-install xmlwriter             
# idk bz2 enchant 

Off topic, but another tip:

If you, like me, need to run ie a framework and want to access your source directory from within your host system (lets say in your IDE for dev purposes), add this in your Dockerfile:
RUN useradd user
Then, you will need to add a config file for your Apache. My preferred way of doing this is mounting it. Anyway, the directory is /etc/apache2/conf-enabled.
In your config you need to add:

User user
Group user

Of course, you will need to replace user with your local user.

Maybe someone can figure out a way to make those missing extensions work.

@chrissound

This comment has been minimized.

Show comment
Hide comment
@chrissound

chrissound Aug 13, 2016

Yup got frustrated with this issue as well: #279

chrissound commented Aug 13, 2016

Yup got frustrated with this issue as well: #279

@francislavoie

This comment has been minimized.

Show comment
Hide comment
@francislavoie

francislavoie Oct 3, 2016

@hp9390 This list is great, but what about for fpm-alpine? We need a list for alpine as well.

francislavoie commented Oct 3, 2016

@hp9390 This list is great, but what about for fpm-alpine? We need a list for alpine as well.

@stubbetje

This comment has been minimized.

Show comment
Hide comment
@stubbetje

stubbetje Nov 3, 2016

Needed ldap module and @MrTrick's comment saved my day

stubbetje commented Nov 3, 2016

Needed ldap module and @MrTrick's comment saved my day

@waspinator

This comment has been minimized.

Show comment
Hide comment
@waspinator

waspinator Dec 3, 2016

installing soap:

RUN apt-get update -y \
  && apt-get install -y \
    libxml2-dev \
    php-soap \
  && apt-get clean -y \
  && docker-php-ext-install soap	

waspinator commented Dec 3, 2016

installing soap:

RUN apt-get update -y \
  && apt-get install -y \
    libxml2-dev \
    php-soap \
  && apt-get clean -y \
  && docker-php-ext-install soap	
@Hipska

This comment has been minimized.

Show comment
Hide comment
@Hipska

Hipska Dec 12, 2016

What about the zip extension? I need it for a project, but ext-install says:

configure: error: zip support requires ZLIB. Use --with-zlib-dir=

to specify prefix where ZLIB include and library are located

I could not figure out which debian package is needed for that.

Hipska commented Dec 12, 2016

What about the zip extension? I need it for a project, but ext-install says:

configure: error: zip support requires ZLIB. Use --with-zlib-dir=

to specify prefix where ZLIB include and library are located

I could not figure out which debian package is needed for that.

@jmkgreen

This comment has been minimized.

Show comment
Hide comment
@jmkgreen

jmkgreen Dec 12, 2016

For zip add libzip-dev first.

jmkgreen commented Dec 12, 2016

For zip add libzip-dev first.

@Hipska

This comment has been minimized.

Show comment
Hide comment
@Hipska

Hipska Dec 12, 2016

Thanks, I already figured it out by using zlib1g-dev are the the same?

Hipska commented Dec 12, 2016

Thanks, I already figured it out by using zlib1g-dev are the the same?

@SanderSander

This comment has been minimized.

Show comment
Hide comment
@SanderSander

SanderSander Jun 14, 2017

For ldap on alpine

FROM php:alpine

RUN apk update && \
    apk add --no-cache --virtual .build-deps $PHPIZE_DEPS icu-dev openldap-dev && \
    docker-php-ext-install ldap && \
    apk del .build-deps && \
    rm -rf /tmp/* /var/cache/apk/*

SanderSander commented Jun 14, 2017

For ldap on alpine

FROM php:alpine

RUN apk update && \
    apk add --no-cache --virtual .build-deps $PHPIZE_DEPS icu-dev openldap-dev && \
    docker-php-ext-install ldap && \
    apk del .build-deps && \
    rm -rf /tmp/* /var/cache/apk/*
@JanGalek

This comment has been minimized.

Show comment
Hide comment
@JanGalek

JanGalek Sep 18, 2017

interbase not work :/

JanGalek commented Sep 18, 2017

interbase not work :/

@rufinus

This comment has been minimized.

Show comment
Hide comment
@rufinus

rufinus Sep 18, 2017

@SanderSander :

May i suggest:

RUN apk update && \
         apk add --no-cache --virtual .build-deps $PHPIZE_DEPS openldap-dev && \
         docker-php-ext-install ldap && \
         apk del .build-deps && \
         rm -rf /tmp/* /var/cache/apk/*

rufinus commented Sep 18, 2017

@SanderSander :

May i suggest:

RUN apk update && \
         apk add --no-cache --virtual .build-deps $PHPIZE_DEPS openldap-dev && \
         docker-php-ext-install ldap && \
         apk del .build-deps && \
         rm -rf /tmp/* /var/cache/apk/*
@SanderSander

This comment has been minimized.

Show comment
Hide comment
@SanderSander

SanderSander Sep 19, 2017

@rufinus Improvement is always welcome 👍 😄

SanderSander commented Sep 19, 2017

@rufinus Improvement is always welcome 👍 😄

@kumarldh

This comment has been minimized.

Show comment
Hide comment
@kumarldh

kumarldh Sep 28, 2017

@hp9390 you might want to add snmp package to the "almost complete" list.

kumarldh commented Sep 28, 2017

@hp9390 you might want to add snmp package to the "almost complete" list.

@hp9390

This comment has been minimized.

Show comment
Hide comment
@hp9390

hp9390 Sep 28, 2017

For reference, I suggest Laradock: https://github.com/laradock/laradock

hp9390 commented Sep 28, 2017

For reference, I suggest Laradock: https://github.com/laradock/laradock

@ehuggett

This comment has been minimized.

Show comment
Hide comment
@ehuggett

ehuggett Sep 29, 2017

Not all Debian releases will use the same package name for the same dependency, support would need to be per-release not just per distro,

ref: #485 , the php-gd extension requires libpng12-dev (jessie) or libpng-dev (stretch)

edit: it seems libpng-dev is a virtual package in jessie, which installs libpng12-dev. This is a bad example for package name differences (as we can use libpng-dev in both?)

ehuggett commented Sep 29, 2017

Not all Debian releases will use the same package name for the same dependency, support would need to be per-release not just per distro,

ref: #485 , the php-gd extension requires libpng12-dev (jessie) or libpng-dev (stretch)

edit: it seems libpng-dev is a virtual package in jessie, which installs libpng12-dev. This is a bad example for package name differences (as we can use libpng-dev in both?)

@skroczek

This comment has been minimized.

Show comment
Hide comment
@skroczek

skroczek Nov 7, 2017

@rufinus @SanderSander
An additional suggest because I got the error:

 PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20160303/ldap.so' - Error loading shared library libldap-2.4.so.2: No such file or directory (needed by /usr/local/lib/php/extensions/no-debug-non-zts-20160303/ldap.so) in Unknown on line 0

I have to add libldap to the persistent-deps

RUN apk add --no-cache --virtual .persistent-deps \
		libldap
RUN apk update && \
         apk add --no-cache --virtual .build-deps $PHPIZE_DEPS openldap-dev && \
         docker-php-ext-install ldap && \
         apk del .build-deps

skroczek commented Nov 7, 2017

@rufinus @SanderSander
An additional suggest because I got the error:

 PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20160303/ldap.so' - Error loading shared library libldap-2.4.so.2: No such file or directory (needed by /usr/local/lib/php/extensions/no-debug-non-zts-20160303/ldap.so) in Unknown on line 0

I have to add libldap to the persistent-deps

RUN apk add --no-cache --virtual .persistent-deps \
		libldap
RUN apk update && \
         apk add --no-cache --virtual .build-deps $PHPIZE_DEPS openldap-dev && \
         docker-php-ext-install ldap && \
         apk del .build-deps

llslim added a commit to llslim/docker-apache-php that referenced this issue Dec 19, 2017

llslim added a commit to llslim/docker-apache-php that referenced this issue Dec 19, 2017

@tianon

This comment has been minimized.

Show comment
Hide comment
@tianon

tianon Dec 22, 2017

Member

I personally find necessary dependencies for PHP extensions the same way I do for any random compiled software I dockerize. The rough process is as follows:

  1. write the Dockerfile such that it downloads, extracts, and attempts to compile the software
  2. when it throws an error, it usually includes the name of a library or header file that's missing:
  • if Alpine, I use https://pkgs.alpinelinux.org/contents to figure out which package contains the file I need (or look for a -dev package of the error message's referenced library)
  • if Debian, I use https://packages.debian.org/file:XYZ.h for searching the archive for packages which provide the files I need (or look for a -dev package of the error message's referenced library)
  1. add the appropriate packages to the Dockerfile, rinse and repeat until the build completes

Sometimes I'll look at the source of the relevant Debian package for clues (from Build-Depends in https://sources.debian.org/src/php7.0/7.0.26-1/debian/control/, for example) or Alpine (from makedepends in https://git.alpinelinux.org/cgit/aports/tree/community/php7/APKBUILD?id=d0ca197f031f96d4664cafaa618aeccf94640a1e, for example).

Regardless, I think it's a huge undertaking to compile a full list of all possible combinations of core extension's dependencies per-PHP-version-per-distro-per-distro-release, and not one the maintainers of this image are willing to undertake. At this point, there are several other official images which are FROM php which install various extensions (https://github.com/docker-library/wordpress/blob/1b48b4bccd7adb0f7ea1431c7b470a40e186f3da/Dockerfile-debian.template#L3-L15, for example), not to mention the wealth of community-maintained images which are also FROM php if someone wanted to use them as a starting point to try and compile such a list as a separate project.

As such, I'm closing this, but appreciate the discussion (and think it serves as a good reference and/or starting point for travelers from the future).

For further discussion of this topic, I'd recommend posting to the Docker Community Forums, the Docker Community Slack, or Stack Overflow in order to capture a wider user base. Thanks!

Member

tianon commented Dec 22, 2017

I personally find necessary dependencies for PHP extensions the same way I do for any random compiled software I dockerize. The rough process is as follows:

  1. write the Dockerfile such that it downloads, extracts, and attempts to compile the software
  2. when it throws an error, it usually includes the name of a library or header file that's missing:
  • if Alpine, I use https://pkgs.alpinelinux.org/contents to figure out which package contains the file I need (or look for a -dev package of the error message's referenced library)
  • if Debian, I use https://packages.debian.org/file:XYZ.h for searching the archive for packages which provide the files I need (or look for a -dev package of the error message's referenced library)
  1. add the appropriate packages to the Dockerfile, rinse and repeat until the build completes

Sometimes I'll look at the source of the relevant Debian package for clues (from Build-Depends in https://sources.debian.org/src/php7.0/7.0.26-1/debian/control/, for example) or Alpine (from makedepends in https://git.alpinelinux.org/cgit/aports/tree/community/php7/APKBUILD?id=d0ca197f031f96d4664cafaa618aeccf94640a1e, for example).

Regardless, I think it's a huge undertaking to compile a full list of all possible combinations of core extension's dependencies per-PHP-version-per-distro-per-distro-release, and not one the maintainers of this image are willing to undertake. At this point, there are several other official images which are FROM php which install various extensions (https://github.com/docker-library/wordpress/blob/1b48b4bccd7adb0f7ea1431c7b470a40e186f3da/Dockerfile-debian.template#L3-L15, for example), not to mention the wealth of community-maintained images which are also FROM php if someone wanted to use them as a starting point to try and compile such a list as a separate project.

As such, I'm closing this, but appreciate the discussion (and think it serves as a good reference and/or starting point for travelers from the future).

For further discussion of this topic, I'd recommend posting to the Docker Community Forums, the Docker Community Slack, or Stack Overflow in order to capture a wider user base. Thanks!

@tianon tianon closed this Dec 22, 2017

@francislavoie

This comment has been minimized.

Show comment
Hide comment
@francislavoie

francislavoie Dec 22, 2017

francislavoie commented Dec 22, 2017

@carnage

This comment has been minimized.

Show comment
Hide comment
@carnage

carnage Dec 23, 2017

@tianon Perhaps add your comments into the README for the project. Point 2 is something I didn't know existed and is a much better resource than googling the specific error message thrown when something fails to compile.

Happy to put in a PR later next week for it if you think it's a good idea but don't have the time.

carnage commented Dec 23, 2017

@tianon Perhaps add your comments into the README for the project. Point 2 is something I didn't know existed and is a much better resource than googling the specific error message thrown when something fails to compile.

Happy to put in a PR later next week for it if you think it's a good idea but don't have the time.

@tianon

This comment has been minimized.

Show comment
Hide comment
@tianon

tianon Dec 26, 2017

Member

@carnage that's a great idea, thanks ❤️

I decided to go with a slightly longer-form explanation in https://tianon.xyz/post/2017/12/26/dockerize-compiled-software.html, which I've sent a PR to link to over in docker-library/docs#1104. 👍

Member

tianon commented Dec 26, 2017

@carnage that's a great idea, thanks ❤️

I decided to go with a slightly longer-form explanation in https://tianon.xyz/post/2017/12/26/dockerize-compiled-software.html, which I've sent a PR to link to over in docker-library/docs#1104. 👍

@GusAntoniassi

This comment has been minimized.

Show comment
Hide comment
@GusAntoniassi

GusAntoniassi Mar 14, 2018

Some extensions that weren't in the list and I had to install:

  • interbase: apt-install firebird-dev libib-util
  • enchant: apt-install libenchant-dev
  • gmp: apt-install libgmp-dev and also run ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h

Note: this was done and tested in Debian, with the php:5.4.45-apache image.

GusAntoniassi commented Mar 14, 2018

Some extensions that weren't in the list and I had to install:

  • interbase: apt-install firebird-dev libib-util
  • enchant: apt-install libenchant-dev
  • gmp: apt-install libgmp-dev and also run ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h

Note: this was done and tested in Debian, with the php:5.4.45-apache image.

@tianon

This comment has been minimized.

Show comment
Hide comment
@tianon

tianon Apr 11, 2018

Member

Those still following along here might want to check out https://github.com/mlocati/docker-php-extension-installer from @mlocati. 👍

Member

tianon commented Apr 11, 2018

Those still following along here might want to check out https://github.com/mlocati/docker-php-extension-installer from @mlocati. 👍

@jungleran

This comment has been minimized.

Show comment
Hide comment
@jungleran

jungleran Apr 12, 2018

FYI, for mcrypt, php 7.2

RUN apt install -y libmcrypt-dev
RUN docker-php-ext-install mcrypt

The mycrypt extension is not provided with the PHP source since 7.2. The way above is not working anymore.

Updated:

RUN apt install libmcrypt-dev -y \
    && pecl install mcrypt-1.0.1 \
    && docker-php-ext-enable mcrypt

jungleran commented Apr 12, 2018

FYI, for mcrypt, php 7.2

RUN apt install -y libmcrypt-dev
RUN docker-php-ext-install mcrypt

The mycrypt extension is not provided with the PHP source since 7.2. The way above is not working anymore.

Updated:

RUN apt install libmcrypt-dev -y \
    && pecl install mcrypt-1.0.1 \
    && docker-php-ext-enable mcrypt
@mlocati

This comment has been minimized.

Show comment
Hide comment
@mlocati

mlocati Apr 12, 2018

@jungleran Thanks for the tips: I just added support for mcrypt under PHP 7.2 in my install-php-extensions script, so that you can install it simply with one line:

install-php-extensions mcrypt

mlocati commented Apr 12, 2018

@jungleran Thanks for the tips: I just added support for mcrypt under PHP 7.2 in my install-php-extensions script, so that you can install it simply with one line:

install-php-extensions mcrypt
@trashbat

This comment has been minimized.

Show comment
Hide comment
@trashbat

trashbat May 14, 2018

@mlocati Thanks very much for this script, it just saved my weekend! I needed to install 30+ extensions and it was getting incredibly tedious figuring out the dependencies and "gotchas" for each one. Your script worked perfectly 👍

trashbat commented May 14, 2018

@mlocati Thanks very much for this script, it just saved my weekend! I needed to install 30+ extensions and it was getting incredibly tedious figuring out the dependencies and "gotchas" for each one. Your script worked perfectly 👍

@Keleir

This comment has been minimized.

Show comment
Hide comment
@Keleir

Keleir Jun 26, 2018

Excuse me. I install ldap extension based php:5.6-fpm-alpine via docker-php-ext-install ldap, but error occurs:

configure: error: Cannot find ldap.h

ERROR: Service 'php' failed to build: The command '/bin/sh -c apk --update add php5-pdo
 php5-mysqli php5-pdo_mysql php5-ldap && docker-php-ext-configure ldap 
 --with-libdir=lib/x86_64-linux-gnu/ && docker-php-ext-install mysqli ldap && 
 rm -rf /var/cache/apk/*' returned a non-zero code: 1

Keleir commented Jun 26, 2018

Excuse me. I install ldap extension based php:5.6-fpm-alpine via docker-php-ext-install ldap, but error occurs:

configure: error: Cannot find ldap.h

ERROR: Service 'php' failed to build: The command '/bin/sh -c apk --update add php5-pdo
 php5-mysqli php5-pdo_mysql php5-ldap && docker-php-ext-configure ldap 
 --with-libdir=lib/x86_64-linux-gnu/ && docker-php-ext-install mysqli ldap && 
 rm -rf /var/cache/apk/*' returned a non-zero code: 1
@rufinus

This comment has been minimized.

Show comment
Hide comment
@rufinus

rufinus Jun 26, 2018

for ldap i use this (with 7.2)

RUN  apk add --no-cache --virtual .build-deps $PHPIZE_DEPS icu-dev openldap-dev && \
    docker-php-ext-install ldap  && \
    docker-php-ext-enable ldap && \
    apk del .build-deps

rufinus commented Jun 26, 2018

for ldap i use this (with 7.2)

RUN  apk add --no-cache --virtual .build-deps $PHPIZE_DEPS icu-dev openldap-dev && \
    docker-php-ext-install ldap  && \
    docker-php-ext-enable ldap && \
    apk del .build-deps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment