How to install mcrypt on Docker

subharb picture subharb · Nov 8, 2017 · Viewed 21.2k times · Source

I have a Docker Container with Phalcon3 and php 7. I am trying to install the php extension Mcrypt without luck.

If I do ssh to the container, and execute:

apt-get update
apt-get install php7.0-mcrypt  

I get the following:

E: Unable to locate package php7.0-mcrypt
E: Couldn't find any package by regex 'php7.0-mcrypt'

Is there a way to get it installed?

Answer

thanosasimo picture thanosasimo · Nov 25, 2018

From PHP manual:

This extension has been moved to the » PECL repository and is no longer bundled with PHP as of PHP 7.2.0.

So in your Dockerfile you have to:

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