Docker php 7.1 imagick:-
pecl install imagick \ && docker-php-ext-enable imagick \
6kkfgxo01#
docker image官方文档:“E:包'php-XXX'没有安装候选项”从docker-library/php#542开始,这个镜像阻止了Debian的PHP包的安装。在docker-library/php#551(comment)中有一些关于这个变化的额外讨论,但要点是在这个镜像中安装Debian的PHP包会导致在一个镜像中安装两个冲突的PHP,这几乎肯定不是预期的结果。对于那些被这一变化破坏的人,在开发适当的修复程序的同时寻找一个变通方法,在你的Dockerfile中添加下面的简单代码行应该可以删除这个块(强烈警告,这将允许安装第二个PHP安装,这绝对不是你想要的,除非你真的知道你在做什么):运行rm /etc/apt/参数设置.d/no-debian-php正确的解决方法是使用FROM debian:XXX直接安装Debian的PHP软件包,或者使用docker-php-ext-install,pecl,和/或phpize安装必要的附加扩展和实用程序。
停靠文件:
FROM php:7.1 RUN apt update && \ apt upgrade && \ apt install -y libmagickwand-dev --no-install-recommends && \ pecl install imagick && docker-php-ext-enable imagick && \ rm -rf /var/lib/apt/lists/*
使用以下工具构建:
$ sudo docker build -t exadra37/php-imagick:7.1 . ... some output ommitted .... s/no-debug-non-zts-20160303/imagick.so Build process completed successfully Installing '/usr/local/lib/php/extensions/no-debug-non-zts-20160303/imagick.so' Installing '/usr/local/include/php/ext/imagick/php_imagick_shared.h' install ok: channel://pecl.php.net/imagick-3.4.3 configuration option "php_ini" is not set to php.ini location You should add "extension=imagick.so" to php.ini Removing intermediate container 71902c85c47a ---> 8142e9efd5ea Successfully built 8142e9efd5ea Successfully tagged exadra37/php-imagick:7.1
检查是否已安装:
$ sudo docker run --rm -it exadra37/php-imagick:7.1 bash root@012656fef3a0:/# php -i | grep -ir imagick - Additional .ini files parsed => /usr/local/etc/php/conf.d/docker-php-ext-imagick.ini imagick imagick module => enabled imagick module version => 3.4.3 imagick classes => Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator, ImagickKernel Imagick compiled with ImageMagick version => ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org Imagick using ImageMagick library version => ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org imagick.locale_fix => 0 => 0 imagick.progress_monitor => 0 => 0 imagick.skip_version_check => 0 => 0 root@012656fef3a0:/#
t30tvxxf2#
来自@Exadra37的答案是正确的。但请注意,您也可以在安装PHP扩展后删除一些APT包(它们只需要编译/安装扩展,而不是使用它-您将保存近200 MB):
FROM php:7.1 RUN apt-get update && \ apt-get install -y libmagickwand-dev && \ pecl install imagick && \ docker-php-ext-enable imagick && \ apt-get remove --purge -y automake autotools-dev bzip2-doc fontconfig gir1.2-freedesktop gir1.2-gdkpixbuf-2.0 gir1.2-glib-2.0 gir1.2-rsvg-2.0 icu-devtools javascript-common libblkid-dev libbz2-dev libcairo-gobject2 libcairo-script-interpreter2 libcairo2 libcairo2-dev libcroco3 libdatrie1 libdjvulibre-dev libdjvulibre-text libdjvulibre21 libelf1 libexif-dev libexif-doc libexif12 libexpat1-dev libffi-dev libfontconfig1-dev libfreetype6-dev libfribidi0 libgdk-pixbuf2.0-0 libgdk-pixbuf2.0-bin libgdk-pixbuf2.0-common libgdk-pixbuf2.0-dev libgirepository-1.0-1 libglib2.0-bin libglib2.0-data libglib2.0-dev libglib2.0-dev-bin libgraphite2-3 libharfbuzz0b libice-dev libice6 libicu-dev libilmbase-dev libilmbase23 libjbig-dev libjpeg-dev libjpeg62-turbo-dev libjs-jquery libjxr-tools libjxr0 liblcms2-dev liblqr-1-0-dev libltdl-dev liblzma-dev liblzo2-2 libmagickcore-6-arch-config libmagickcore-6-headers libmagickcore-6.q16-6-extra libmagickcore-6.q16-dev libmagickwand-6-headers libmagickwand-6.q16-dev libmagickwand-dev libmount-dev libmpdec2 libopenexr-dev libopenexr23 libopenjp2-7-dev libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpcre16-3 libpcre3-dev libpcre32-3 libpcrecpp0v5 libpixman-1-0 libpixman-1-dev libpng-dev libpng-tools libpthread-stubs0-dev libpython3-stdlib libpython3.7-minimal libpython3.7-stdlib libreadline7 librsvg2-2 librsvg2-common librsvg2-dev libselinux1-dev libsepol1-dev libsm-dev libsm6 libthai-data libthai0 libtiff-dev libtiffxx5 libtool libwmf-dev libwmf0.2-7 libx11-dev libxau-dev libxcb-render0 libxcb-render0-dev libxcb-shm0 libxcb-shm0-dev libxcb1-dev libxdmcp-dev libxext-dev libxml2-dev libxrender-dev libxrender1 libxt-dev libxt6 mime-support python3 python3-distutils python3-lib2to3 python3-minimal python3.7 python3.7-minimal readline-common shared-mime-info uuid-dev x11-common x11proto-core-dev x11proto-dev x11proto-xext-dev xorg-sgml-doctools xtrans-dev zlib1g-dev && \ rm -rf /var/lib/apt/lists/*
管理所需APT包的列表可能会很混乱,所以我开发了一个脚本来做这件事。你可以简单地写这样的东西:
FROM php:7.1 COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/ RUN install-php-extensions imagick
此install-php-extensions脚本支持此处列出的PHP扩展
install-php-extensions
2条答案
按热度按时间6kkfgxo01#
docker image官方文档:
“E:包'php-XXX'没有安装候选项”
从docker-library/php#542开始,这个镜像阻止了Debian的PHP包的安装。在docker-library/php#551(comment)中有一些关于这个变化的额外讨论,但要点是在这个镜像中安装Debian的PHP包会导致在一个镜像中安装两个冲突的PHP,这几乎肯定不是预期的结果。
对于那些被这一变化破坏的人,在开发适当的修复程序的同时寻找一个变通方法,在你的Dockerfile中添加下面的简单代码行应该可以删除这个块(强烈警告,这将允许安装第二个PHP安装,这绝对不是你想要的,除非你真的知道你在做什么):
运行rm /etc/apt/参数设置.d/no-debian-php
正确的解决方法是使用FROM debian:XXX直接安装Debian的PHP软件包,或者使用docker-php-ext-install,pecl,和/或phpize安装必要的附加扩展和实用程序。
解决方案
停靠文件:
使用以下工具构建:
检查是否已安装:
t30tvxxf2#
来自@Exadra37的答案是正确的。但请注意,您也可以在安装PHP扩展后删除一些APT包(它们只需要编译/安装扩展,而不是使用它-您将保存近200 MB):
管理所需APT包的列表可能会很混乱,所以我开发了一个脚本来做这件事。你可以简单地写这样的东西:
此
install-php-extensions
脚本支持此处列出的PHP扩展