我需要将imagemagick添加到我的php7.4 docker中,所以在文件Dockerfile.yml中我添加了:
FROM php:7.4.1-apache
RUN apt-get update && \
apt-get install -y \
python \
libfreetype6-dev \
libwebp-dev \
libjpeg62-turbo-dev \
libpng-dev \
libzip-dev \
nano \
mc \
git-core \
libmagickwand-dev --no-install-recommends && \
pecl install imagick && imagick && \
docker-php-ext-enable imagick && \
curl ...
RUN docker-php-ext-install \
gd pdo pdo_mysql zip gmp bcmath pcntl ldap sysvmsg exif && \
a2enmod rewrite
RUN install-php-extensions imagick
COPY virtualhost.conf /etc/apache2/sites-enabled/000-default.conf
但我得到了错误:
Build process completed successfully
Installing '/usr/local/lib/php/extensions/no-debug-non-zts-20190902/imagick.so'
Installing '/usr/local/include/php/ext/imagick/php_imagick_shared.h'
install ok: channel://pecl.php.net/imagick-3.5.1
configuration option "php_ini" is not set to php.ini location
You should add "extension=imagick.so" to php.ini
/bin/sh: 1: imagick: not found
ERROR: Service 'web' failed to build: The command '/bin/sh -c apt-get update && apt-get install -y python libfreetype6-dev libwebp-dev libjpeg62-turbo-dev libpng-dev libzip-dev nano mc git-core libmagickwand-dev --no-install-recommends && pecl install imagick && imagick && docker-php-ext-enable imagick && curl build-essential openssl libssl-dev libgmp-dev libldap2-dev netcat locate && git clone https://github.com/nodejs/node.git && cd node && git checkout v12.0.0 && ./configure && make && make install' returned a non-zero code: 127
我的Dockerfile.yml中有什么问题,如何修复?
**已更新# 2:**我修改了Dockerfile.yml:
FROM php:7.4.1-apache
RUN apt-get update && \
# apt-get install -y \
apt-get install --assume-yes --no-install-recommends --quiet \
python \
libfreetype6-dev \
libwebp-dev \
libjpeg62-turbo-dev \
libpng-dev \
libzip-dev \
nano \
mc \
git-core \
libmagickwand-dev \
curl \
build-essential \
openssl \
libssl-dev \
libgmp-dev \
libldap2-dev \
netcat \
locate \
# composer \
&& git clone https://github.com/nodejs/node.git && \
cd node \
&& git checkout v12.0.0 \
&& ./configure \
&& make \
&& make install
RUN pecl install imagick \
&& docker-php-ext-enable imagick
RUN npm install cross-env
RUN npm install -g yarn
# RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-webp-dir=/usr/include/ --with-jpeg-dir=/usr/include/
RUN docker-php-ext-configure gd --with-freetype --with-jpeg
# READ https://github.com/docker-library/php/issues/912#issuecomment-559918036
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN docker-php-ext-install gd pdo pdo_mysql zip gmp bcmath pcntl ldap sysvmsg exif \
&& a2enmod rewrite
RUN apt-get install -y grep mlocate
RUN docker-php-ext-install imagick
COPY virtualhost.conf /etc/apache2/sites-enabled/000-default.conf
但跑步:
docker-compose up -d --build
我在输出中得到了后周:
Need to get 97.7 kB of archives.
After this operation, 504 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian buster/main amd64 mlocate amd64 0.26-3 [97.7 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 97.7 kB in 0s (729 kB/s)
Selecting previously unselected package mlocate.
(Reading database ... 22379 files and directories currently installed.)
Preparing to unpack .../mlocate_0.26-3_amd64.deb ...
Unpacking mlocate (0.26-3) ...
Setting up mlocate (0.26-3) ...
update-alternatives: using /usr/bin/mlocate to provide /usr/bin/locate (locate) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/man1/locate.1.gz because associated file /usr/share/man/man1/mlocate.1.gz (of link group locate) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man8/updatedb.8.gz because associated file /usr/share/man/man8/updatedb.mlocate.8.gz (of link group locate) doesn't exist
Adding group `mlocate' (GID 101) ...
Done.
Removing intermediate container 40f86f34f2af
---> edaee648df84
Step 10/11 : RUN docker-php-ext-install imagick
---> Running in a72d0887a6b0
error: /usr/src/php/ext/imagick does not exist
usage: /usr/local/bin/docker-php-ext-install [-jN] ext-name [ext-name ...]
ie: /usr/local/bin/docker-php-ext-install gd mysqli
/usr/local/bin/docker-php-ext-install pdo pdo_mysql
/usr/local/bin/docker-php-ext-install -j5 gd mbstring mysqli pdo pdo_mysql shmop
if custom ./configure arguments are necessary, see docker-php-ext-configure
Possible values for ext-name:
bcmath bz2 calendar ctype curl dba dom enchant exif ffi fileinfo filter ftp gd gettext gmp hash iconv imap intl json ldap mbstring mysqli oci8 odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix pspell readline reflection session shmop simplexml snmp soap sockets sodium spl standard sysvmsg sysvsem sysvshm tidy tokenizer xml xmlreader xmlrpc xmlwriter xsl zend_test zip
Some of the above modules are already compiled into PHP; please check
the output of "php -i" to see which modules are already loaded.
ERROR: Service 'web' failed to build: The command '/bin/sh -c docker-php-ext-install imagick' returned a non-zero code: 1
我该如何修复它?
提前感谢!
1条答案
按热度按时间nkoocmlb1#
该消息
这只是一个警告,稍后会在您的Dockerfile中解决。真实的的错误是由执行不存在的二进制
imagick
引起的。您可以按如下方式简化您的Dockerfile:
这样应该可以解决问题。
输出量: