Docker PHP 7.1的imagick [英] Docker php 7.1 imagick
问题描述
Docker php 7.1 imagick:-
Docker php 7.1 imagick:-
pecl install imagick \
&& docker-php-ext-enable imagick \
没有适用于软件包"pecl.php.net/imagick"的发行版安装失败
No releases available for package "pecl.php.net/imagick" install failed
错误:服务'app'构建失败
ERROR: Service 'app' failed to build
推荐答案
来自官方 docker图片文档:
"E:软件包'php-XXX'没有安装候选对象""
"E: Package 'php-XXX' has no installation candidate"
从docker-library/php#542开始,此图像阻止Debian的PHP软件包的安装.docker-library/php#551(注释)中对此更改进行了其他讨论,但要点是,在此映像中安装Debian的PHP软件包会在单个映像中导致两次冲突的PHP安装,这几乎肯定不是预期的结果.
As of docker-library/php#542, this image blocks the installation of Debian's PHP packages. There is some additional discussion of this change in docker-library/php#551 (comment), but the gist is that installing Debian's PHP packages in this image leads to two conflicting installations of PHP in a single image, which is almost certainly not the intended outcome.
对于那些被此更改破坏并在开发适当的修补程序的同时寻求解决方法的人,在Dockerfile中添加以下简单行应删除该块(强烈警告:这将允许安装第二次安装PHP,除非您真的知道自己在做什么,否则绝对不是您要找的东西:
For those broken by this change and looking for a workaround to apply in the meantime while a proper fix is developed, adding the following simple line to your Dockerfile should remove the block (with the strong caveat that this will allow the installation of a second installation of PHP, which is definitely not what you're looking for unless you really know what you're doing):
运行rm/etc/apt/preferences.d/no-debian-php
RUN rm /etc/apt/preferences.d/no-debian-php
此错误的正确解决方案是要么使用FROM debian:XXX并直接安装Debian的PHP软件包,要么使用docker-php-ext-install,pecl和/或phpize安装必要的其他扩展和实用程序.
The proper solution to this error is to either use FROM debian:XXX and install Debian's PHP packages directly, or to use docker-php-ext-install, pecl, and/or phpize to install the necessary additional extensions and utilities.
解决方案
Dockerfile:
The Solution
Dockerfile:
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:/#
这篇关于Docker PHP 7.1的imagick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!