我正在构建一个从源代码安装PHP的基本映像,并试图安装一些扩展。我在扩展安装中发现了一些不一致之处,并在寻找一些清晰的地方。我把码头文件的某些部分排除在外。
FROM private-registry:hardened-ubuntu20:latest as base
COPY --from=php:7.4-fpm /usr/local/bin/docker-php-ext-install /usr/local/bin/docker-php-ext-install
COPY --from=php:7.4-fpm /usr/local/bin/docker-php-source /usr/local/bin/docker-php-source
COPY --from=php:7.4-fpm /usr/local/bin/docker-php-ext-enable /usr/local/bin/docker-php-ext-enable
COPY --from=php:7.4-fpm /usr/local/bin/docker-php-ext-configure /usr/local/bin/docker-php-ext-configure
COPY --from=php:7.4-fpm /usr/local/bin/phpize /usr/local/bin/phpize
COPY --from=php:7.4-fpm /usr/src/php.tar.xz /usr/src/php.tar.xz
ENV PHP_INI_DIR=/usr/local/etc/php
RUN apt-get update \
&& apt-get install -y \
#PHP extension requirements
RUN docker-php-source extract \
&& cd /usr/src/php \
&& ./configure \
--enable-fpm \
--with-fpm-user=www-data \
--with-fpm-group=www-data \
--enable-mysqlnd \
--with-pdo-mysql=mysqlnd \
--enable-mbstring \
--with-openssl \
&& make \
&& make install \
&& docker-php-source delete当我使用所需的扩展运行时,所有的安装似乎都是正确的,并且我的子映像能够获取它们。
但是,在上面的片段中,如果我删除--enable-mbstring行并尝试使用docker-php-ext-install mbstring安装它,子映像似乎没有安装扩展。.ini文件是按预期在/usr/local/etc/php/conf.d中创建的,它出现在子图像中,但没有满足要求。如果我删除--enable-mysqlnd并尝试使用docker-php-ext-install mysqli进行安装,情况也是如此。
因此,为了巩固,如果我省略了任何配置选项,并且只使用docker-php-ext-install安装我的扩展,则安装似乎无法工作。我可以在基本映像中的./configure调用中包含所有必需的扩展,但这是有问题的,因为我们系统中的一些子映像正在它们的Dockerfile中调用docker-php-ext-install,并且我们希望能够更改基本映像而不需要对子映像进行任何更改。底线是,docker-php-ext-install必须工作。
,例如
FROM parent-image-with-php-from-source
...
docker-php-ext-install bcmath
...子图像生成输出:bcMath似乎安装正确,但在后面的层中,这一要求没有得到满足。
...
PATH="$PATH:/sbin" ldconfig -n /usr/src/php/ext/bcmath/modules
----------------------------------------------------------------------
Libraries have been installed in:
/usr/src/php/ext/bcmath/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,--rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Build complete.
Don't forget to run 'make test'.
...
Step 21/29 : RUN composer install --no-cache --no-scripts --no-autoloader --no-ansi --no-dev --optimize-autoloader --no-interaction --no-progress --prefer-dis
t
---> Running in ace1fd609a27
Installing dependencies from lock file
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested PHP extension ext-bcmath * is missing from your system. Install or enable PHP's bcmath extension.
Problem 2
- Installation request for s1lentium/iptools v1.1.1 -> satisfiable by s1lentium/iptools[v1.1.1].
- s1lentium/iptools v1.1.1 requires ext-bcmath * -> the requested PHP extension bcmath is missing from your system.
Problem 3
- Installation request for sabre/http 5.1.1 -> satisfiable by sabre/http[5.1.1].
- sabre/http 5.1.1 requires ext-curl * -> the requested PHP extension curl is missing from your system.
Problem 4
- s1lentium/iptools v1.1.1 requires ext-bcmath * -> the requested PHP extension bcmath is missing from your system.
- casbin/casbin v2.4.0 requires s1lentium/iptools ^1.1 -> satisfiable by s1lentium/iptools[v1.1.1].
- Installation request for casbin/casbin v2.4.0 -> satisfiable by casbin/casbin[v2.4.0].
The command '/bin/sh -c composer install --no-cache --no-scripts --no-autoloader --no-ansi --no-dev --optimize-autoloader --no-interaction --no-progress --pr
efer-dist' returned a non-zero code: 2任何洞察力都将不胜感激。我想知道是否可以像修改路径一样简单,但我不确定。
发布于 2021-08-09 20:20:09
我想我发现了这个问题-
我需要在我的./configure调用中添加以下标志
--with-config-file-scan-dir=/usr/local/etc/php/conf.d \
--with-config-file-path=/usr/local/etc/php \现在,子图像知道在哪里查找docker-php-ext-*..ini文件。
https://stackoverflow.com/questions/68715569
复制相似问题