简体   繁体   English

docker php:7.1-fpm-alpine 无法构建 GD

[英]docker php:7.1-fpm-alpine fails to build GD

Trying to build from the official php:7.1-fpm-alpine image, using the following excerpt in my Dockerfile:尝试从官方php:7.1-fpm-alpine镜像构建,使用我的 Dockerfile 中的以下摘录:

FROM php:7.1-fpm-alpine

RUN set -ex \
    apk add --no-cache --virtual .build-deps \
    freetype-dev \
    libjpeg-turbo-dev \
    libpng-dev \
\
    && docker-php-ext-configure gd \
        --with-freetype-dir=/usr \
        --with-png-dir=/usr \
        --with-jpeg-dir=/usr \
    && docker-php-ext-install gd \
    && apk del .build-deps

When attempting to build this with docker build , GD fails during ./configure with the following error:尝试使用docker build ,GD 在./configure期间失败并出现以下错误:

configure: error: jpeglib.h not found

I can confirm that jpeglib.h exists and is exactly where I think it should be (indeed, exactly where it is in Debian variants):我可以确认jpeglib.h存在并且正是我认为它应该在的地方(实际上,它在 Debian 变体中的确切位置):

$ docker run -it --rm php:7.1-fpm-alpine /bin/sh
>$ apk add --no-cache libjpeg-turbo-dev \
   && find /usr -type f -name 'jpeglib.h'
   ...
   /usr/include/jpeglib.h

But if I take exactly the same command used in the dockerfile and run it interactively inside the container, it builds flawlessly.但是如果我使用 dockerfile 中使用的完全相同的命令并在容器内以交互方式运行它,它就会完美地构建。 No errors.没有错误。

Is this a bug, or am I missing something?这是一个错误,还是我错过了什么?

The problem was a blindingly simple syntax error;问题是一个非常简单的语法错误; the apk call following the set command needs to be preceded by && , otherwise the interpreter is treating the entire apk call as a set of arguments to set .apk以下的呼叫set命令需要在前面加&& ,否则解释器处理的整个apk呼叫作为一组参数来set In that case, the packages aren't added, therefore jpeglib.h didn't exist.在这种情况下,不会添加包,因此jpeglib.h不存在。

When I typed the command into the shell, I used the correct syntax, so it passed without error.当我在 shell 中输入命令时,我使用了正确的语法,所以它没有错误地通过。

yes, you should write like this是的,你应该这样写

RUN set -ex \
    && apk add --no-cache --virtual .build-deps \

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Docker 构建:扩展未通过 apk 加载:exif、gd、pdo_mysql、pecl-redis。 我该怎么做才能修复我的 dockerfile? 来自 php:7.4-fpm-alpine - Docker build: Extentions not loading via apk: exif, gd, pdo_mysql, pecl-redis. What can I do to fix my dockerfile? From php:7.4-fpm-alpine docker 文件 alpine 的正确语法与 --platform 和 php fpm-alpine - correct syntax for docker file alpine with --platform and php fpm-alpine php:7.4-fpm-alpine - 无效配置“gd”:机器“gd-unknown”无法识别 - php:7.4-fpm-alpine - Invalid configuration `gd': machine `gd-unknown' not recognized Docker php-fpm-alpine:如何抑制警告 - Docker php-fpm-alpine: How to supress warnings 如何在 Docker php-fpm alpine 中安装 LDAP - How to install LDAP in Docker php-fpm alpine 无法在 docker alpine 版本 3.14 或最新版本上安装 php-gd - Impossible to install php-gd on docker alpine version 3.14 or newest docker php:8.1.1-fpm-alpine3.15 上的 Npm 权限被拒绝 - Npm permission denied on docker php:8.1.1-fpm-alpine3.15 如何在 php:5.6-fpm-alpine docker 容器中启用 Memcache - How to enable Memcache in php:5.6-fpm-alpine docker container 如何在 php:7.4-fpm-alpine docker 容器中启用 xdebug? - How to enable xdebug in php:7.4-fpm-alpine docker container? 带有 SQLSRV 驱动程序错误的 Docker PHP-FPM Alpine - Docker PHP-FPM Alpine with SQLSRV Driver Error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM