Search code examples
dockermcryptphp-5.6

php:5-apache mcrypt.h not found


I work on some old project (Laravel 4.2) which use mcrypt and php5 and wanna run it on docker. Here is my dockerfile:

FROM php:5-apache

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

RUN apt-get update &&\
    apt-get install -y \
    git \
    libpng-dev \
    zlib1g-dev \
    zip \
    unzip &&\
    a2enmod rewrite

RUN docker-php-ext-install pdo 
RUN docker-php-ext-install pdo_mysql 
RUN docker-php-ext-install zip
RUN docker-php-ext-install gd 
RUN docker-php-ext-install pcntl  
RUN docker-php-ext-install mcrypt  

After run I get message:

configure: error: mcrypt.h not found. Please reinstall libmcrypt.

I try to add libmcrypt under apt-get install in above file but I get:

E: Unable to locate package libmcrypt

In similar way I try to add php5-mcrypt but I get:

E: Package 'php5-mcrypt' has no installation candidate

If I use (and combine with above) FROM php:5-apache-jessie and add line RUN rm /etc/apt/preferences.d/no-debian-php before RUN apt-get update &&\ i still get above errors.

Question: How to solve this?


Solution

  • Instead of use libmcrypt or php5-mcrypt (below line apt-get install -y \) just use following library in dockerfile:

    libmcrypt-dev \