How to install extension for php via docker-php-ext-install? How to install extension for php via docker-php-ext-install? docker docker

How to install extension for php via docker-php-ext-install?


I had the same problem a while ago. I started a container and typed the ext-install command into this container. Once I found all the dependencies, I wrote them into the Dockerfile.

Example:

RUN apt-get update && apt-get install -y \libmcrypt-dev \&& docker-php-ext-install -j$(nproc) mcrypt

There is a dependency that libmcrypt-dev needed before you can run docker-php-ext-install mcrypt

I've checked my older Dockerfiles and found something which might help you

FROM php:5.6-apacheRUN apt-get update && apt-get install -y \        libfreetype6-dev \        libjpeg62-turbo-dev \        libmcrypt-dev \        libpng12-dev \    libicu-dev \     libxml2-dev \    vim \        wget \        unzip \        git \    && docker-php-ext-install -j$(nproc) iconv intl xml soap mcrypt opcache pdo pdo_mysql mysqli mbstring \    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \    && docker-php-ext-install -j$(nproc) gdRUN a2enmod rewrite && mkdir /composer-setup && wget https://getcomposer.org/installer -P /composer-setup && php /composer-setup/installer --install-dir=/usr/bin && rm -Rf /composer-setup && curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony && chmod a+x /usr/local/bin/symfony# Create symlink for default confRUN ln -s /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-enabled/000-default.conf && mkdir /composer-setup && wget https://getcomposer.org/installer -P /composer-setup && php /composer-setup/installer --install-dir=/usr/bin && rm -Rf /composer-setup && curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony && chmod a+x /usr/local/bin/symfony


RUN docker-php-ext-install mbstring pdo pdo_mysql \

That code can do install any extension you want in this case mysql pdp driver but the Dockerfile should have base of FROM php:7.1.8-apache


The 2019 way and probably the 2020 way of installing memcached to your Docker PHP container is the way described on https://hub.docker.com/_/php

FROM php:latestRUN pecl install memcached \    && docker-php-ext-enable memcached
FROM php:5.6-cliRUN apt-get update && apt-get install -y libmemcached-dev zlib1g-dev \    && pecl install memcached-2.2.0 \    && docker-php-ext-enable memcached