MrVirussS
MrVirussS

Reputation: 23

How to fix Docker "/usr/src/php/ext/mcrypt does not exist" build error?

I try to install mcrypt in my docker image based on php:7.2-apache. Therefore I use the RUN-Command from the documentation and also answerd here but I receive this error. I think maybe while setup may be missing.

This is my app.docker file.

    FROM php:7-fpm

# Install any custom system requirements here
RUN apt-get update \
  && apt-get install -y --no-install-recommends \
    libfreetype6-dev \
    libjpeg62-turbo-dev \
    libpng-dev \
    curl \
    vim \
    cron \
    procps \
    zlib1g-dev \
    zip

RUN apt-get update && apt-get install -y libmcrypt-dev mysql-client \
    && docker-php-ext-install pdo_mysql \
    && 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 \
    && docker-php-ext-install zip \
    && docker-php-ext-install bcmath \
    && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

WORKDIR /var/www

report error in when build docker.

>         error: /usr/src/php/ext/mcrypt does not exist
>     
>     usage: /usr/local/bin/docker-php-ext-install [-jN] ext-name [ext-name ...]
>        ie: /usr/local/bin/docker-php-ext-install gd mysqli
>            /usr/local/bin/docker-php-ext-install pdo pdo_mysql
>            /usr/local/bin/docker-php-ext-install -j5 gd mbstring mysqli pdo pdo_mysql shmop
>     
>     if custom ./configure arguments are necessary, see docker-php-ext-configure
>     
>     Possible values for ext-name:
>     bcmath bz2 calendar ctype curl dba dom enchant exif fileinfo filter ftp gd gettext gmp hash iconv imap interbase intl json ldap
> mbstring mysqli oci8 odbc opcache pcntl pdo pdo_dblib pdo_firebird
> pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix
> pspell readline recode reflection session shmop simplexml snmp soap
> sockets sodium spl standard sysvmsg sysvsem sysvshm tidy tokenizer
> wddx xml xmlreader xmlrpc xmlwriter xsl zend_test zip
>     
>     Some of the above modules are already compiled into PHP; please check
>     the output of "php -i" to see which modules are already loaded.
>     ERROR: Service 'app' failed to build: The command '/bin/sh -c apt-get update && apt-get install -y libmcrypt-dev mysql-client     &&
> docker-php-ext-install pdo_mysql     && 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     && docker-php-ext-install zip
> && docker-php-ext-install bcmath     && curl -sS
> https://getcomposer.org/installer | php --
> --install-dir=/usr/local/bin --filename=composer' returned a non-zero code: 1

Even though the path to the is specified in Dockerfile, it says not found

Anyone know why?

Upvotes: 2

Views: 9745

Answers (2)

Shōgun8
Shōgun8

Reputation: 562

This worked for me, copied from here:

RUN apt-get update && apt-get install -y libmcrypt-dev \
    && pecl install mcrypt-1.0.2 \
    && docker-php-ext-enable mcrypt

Upvotes: 3

KBA7
KBA7

Reputation: 41

This is because mcrypt is deprecated after php:7.1. You can use a base image which still supports mcrypt eg php:5.6-cli or use an alternative to mcrypt.

Upvotes: 3

Related Questions