如何在 Docker 上安装 mcrypt

How to install mcrypt on Docker

我有一个 Docker 带有 Phalcon3 和 php 7 的容器。我正在尝试安装 php 扩展 Mcrypt,但不幸的是。

如果我对容器执行 ssh,并执行:

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

我得到以下信息:

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

有没有办法安装它?

让我们看看 php docker image 部分 PHP 核心扩展

的官方手册

For example, if you want to have a PHP-FPM image with iconv, mcrypt and gd extensions, you can inherit the base image that you like, and write your own Dockerfile like this:

FROM php:7.0-fpm
RUN apt-get update && apt-get install -y \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libmcrypt-dev \
        libpng-dev \
    && 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

Rember, you must install dependencies for your extensions manually. If an extension needs custom configure arguments, you can use the docker-php-ext-configure script like this example. There is no need to run docker-php-source manually in this case, since that is handled by the configure and install scripts.

来自 PHP 手册:

此扩展已移至 » PECL 存储库,从 PHP 7.4.0 起不再与 PHP 捆绑。

因此在您的 Dockerfile 中您必须:

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