2

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?

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Well whats an alternative?
@Octavian That kinda depends on why you need mcrypt in the first place. If it's a library you're using, it may need an updated version (like going from Laravel 4 to 5). If it's your own code, the replacement is php.net/manual/en/function.openssl-encrypt.php.
3

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

1 Comment

This is how I resolved as well. Is a good one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.