如何修复Docker“ / usr / src / php / ext / mcrypt不存在”的构建错误?

时间:2019-03-06 06:18:45

标签: docker

我尝试在基于php:7.2-apache的docker映像中安装mcrypt。因此,我使用文档中的RUN-Command并在此处回答,但收到此错误。我认为也许安装程序可能会丢失。

这是我的app.docker文件。

    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

在构建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

即使在Dockerfile中指定了的路径,也显示未找到

有人知道为什么吗?

2 个答案:

答案 0 :(得分:2)

这是因为在php:7.1之后不推荐使用mcrypt。您可以使用仍支持mcrypt的基本映像,例如php:5.6-cli或使用mcrypt的替代方案。

答案 1 :(得分:0)

这对我有用,复制自here

intersect = pd.merge(df1, df2, how='inner')