dongzhaobai5982 2017-10-18 08:26
浏览 160
已采纳

Docker php:fpm-install php扩展

I am using the official php:fpm docker image as base for my application container, so the Dockerfile starts like so:

FROM php:fpm

Later in the file I would like to have something like that:

RUN apt-get install -y \
    php7.0-gd

But that tells me:

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

»Bashing« into the container using docker exec -it <name> /bin/bash and executing: apt-cache search php | grep gd yields:

php5-gdcm - Grassroots DICOM PHP5 bindings
php5-vtkgdcm - Grassroots DICOM VTK PHP bindings
php5-gd - GD module for php5

So since that is a debian (yessie) based image, only the old php5 packages are available and php7 is installed by some tricky script in the php:fpm dockerfile and it seams that all extensions are compiled within the used php executable.

How can I install more extensions in this scenario?

  • 写回答

1条回答 默认 最新

  • duanniu3385 2017-10-18 08:53
    关注

    Quoting https://hub.docker.com/_/php/

    How to install more PHP extensions

    We provide the helper scripts docker-php-ext-configure, docker-php-ext-install, and docker-php-ext-enable to more easily install PHP extensions.

    To install PHP with iconv, mcrypt and GD, they provide the following example:

    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
    

    Please refer to the Dockerhub page for more details.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号