Dockerfile - 运行apt-get install -y php5-MODULES不再工作 - “没有安装应用程序”。如何解决它?

我有一个图像php5.6 + apache,自3周前开始使用,当我构建它时,通过Dockerfile。我使用base image来启动我的图像。 一切都很好,直到今天,当我不得不改变php.ini中的一些变量。Dockerfile - 运行apt-get install -y php5-MODULES不再工作 - “没有安装应用程序”。如何解决它?

现在,当我尝试建立图像再次我收到此错误:

Step 5/173 : RUN apt-get install -y php5-common 

---> Running in 8114082e9931

Reading package lists...

Building dependency tree...

Reading state information...

Package php5-common is not available, but is referred to by another package.

This may mean that the package is missing, has been obsoleted, or

is only available from another source

E: Package 'php5-common' has no installation candidate

The command '/bin/sh -c apt-get install -y php5-common' returned a non-zero code: 100

它似乎正在发生的事情对每个PHP模块,我尝试安装。

这里是Dockerfile的一部分:

FROM php:5-apache 

## Update apt-get

RUN apt-get update

RUN php -m

RUN php -v

RUN apt-get install -y php5-common

RUN apt-get install -y php-calendar

RUN docker-php-ext-install bcmath

RUN apt-get install -y php5-mhash

RUN apt-get install -y php5-intl

RUN cp /etc/php5/mods-available/intl.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/intl.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/intl.so

RUN apt-get install -y php5-mcrypt

RUN cp /etc/php5/mods-available/mcrypt.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/mcrypt.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/mcrypt.so

RUN apt-get install -y php5-redis

RUN cp /etc/php5/mods-available/redis.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/redis.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/redis.so

RUN apt-get install -y php5-mysql

RUN cp /etc/php5/mods-available/mysql.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/mysql.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/mysql.so

RUN cp /etc/php5/mods-available/opcache.ini /usr/local/etc/php/conf.d

RUN apt-get install -y php5-gd

RUN cp /etc/php5/mods-available/gd.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/gd.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/gd.so

RUN apt-get install -y php5-gdcm

RUN cp /etc/php5/mods-available/gdcm.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/gdcm.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/gdcm.so

RUN apt-get install -y php5-vtkgdcm

RUN cp /etc/php5/mods-available/vtkgdcm.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/vtkgdcm.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/vtkgdcm.so

RUN apt-get install -y php5-ldap

RUN cp /etc/php5/mods-available/ldap.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/ldap.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/ldap.so

RUN apt-get install -y php5-xsl

RUN cp /etc/php5/mods-available/xsl.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/xsl.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/xsl.so

RUN apt-get install -y php5-tidy

RUN cp /etc/php5/mods-available/tidy.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/tidy.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/tidy.so

RUN apt-get install -y php5-xmlrpc

RUN cp /etc/php5/mods-available/xmlrpc.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/xmlrpc.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/xmlrpc.so

RUN apt-get install -y php5-pgsql

RUN cp /etc/php5/mods-available/pgsql.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/pgsql.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/pgsql.so

RUN cp /etc/php5/mods-available/mysqli.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/mysqli.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/mysqli.so

RUN cp /etc/php5/mods-available/pdo.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/pdo.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/pdo.so

RUN cp /etc/php5/mods-available/pdo_mysql.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/pdo_mysql.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/pdo_mysql.so

RUN cp /etc/php5/mods-available/pdo_pgsql.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/pdo_pgsql.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/pdo_pgsql.so

RUN cp /etc/php5/mods-available/readline.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/readline.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/readline.so

#COPYING__php.ini

RUN cp /etc/php5/cli/php.ini /usr/local/etc/php/

RUN ls -l /usr/local/etc/

## Setting up php.ini varaibles

RUN grep '^post_max_size' /usr/local/etc/php/php.ini

RUN sed -i 's,^post_max_size =.*$,post_max_size = 2048M,' /usr/local/etc/php/php.ini

RUN grep '^post_max_size' /usr/local/etc/php/php.ini

RUN grep '^upload_max_filesize' /usr/local/etc/php/php.ini

RUN sed -i 's,^upload_max_filesize =.*$,upload_max_filesize = 2048M,' /usr/local/etc/php/php.ini

RUN grep '^upload_max_filesize' /usr/local/etc/php/php.ini

...

基本上has no installation candidate错误这是工作3个星期前所有模块。

我怎么能解决这个问题?

UPDATE

遵循问题看到这个POST

回答:

PHP官方容器图像自带助手使它更容易些。这些示例直接来自the PHP repository on Docker。

安装核心扩展mcyrpt你将以下内容添加到您的Dockerfile

RUN docker-php-ext-install -j$(nproc) mcrypt 

一些扩展需要在系统上存在的库(因为当你建立你的容器中的扩展已经编译)。请注意,在这个例子中,所有的命令串在一起,你可能作为一个个人发出RUN

RUN apt-get update && apt-get install -y libfreetype6-dev \ 

libjpeg62-turbo-dev \

libmcrypt-dev \

libpng-dev

&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \

&& docker-php-ext-install -j$(nproc) gd

对于PECL扩展,像redismemcached你让pecl install处理安装,然后使用docker-php-ext-enable添加相应的.ini文件(S)。与上面的gd示例不同,某些PECL扩展有它们自己的依赖关系,所以您在安装之前使用apt-get install -y ...添加这些扩展。

RUN pecl install redis-3.1.0 && docker-php-ext-enable redis 

报料它一起,它可能看起来像这样添加gdredismcrypt

FROM php:5-apache 

RUN apt-get update && apt-get install -y libfreetype6-dev \

libjpeg62-turbo-dev \

libmcrypt-dev \

libpng-dev

&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \

&& docker-php-ext-install -j$(nproc) gd

RUN docker-php-ext-install -j$(nproc) mcrypt

RUN pecl install redis-3.1.0 && docker-php-ext-enable redis

RUN php -m

回答:

如果你看一下Dockerfile您提供的link到,它有这些行:中-1Pin-Priority

# prevent Debian's PHP packages from being installed 

# https://github.com/docker-library/php/pull/542

RUN set -eux; \

{ \

echo 'Package: php*'; \

echo 'Pin: release *'; \

echo 'Pin-Priority: -1'; \

} > /etc/apt/preferences.d/no-debian-php

偏爱PHP软件包时,告诉系统不安装这些软件包。 而拉请求正在解释为什么https://github.com/docker-library/php/pull/542。

要解决您的问题,您必须使用内置的docker-php-ext-install命令来安装PHP程序包。这里是他们的官方页面的例子https://hub.docker.com/_/php/:

FROM php:5-apache 

RUN apt-get update && apt-get install -y \

libfreetype6-dev \

libjpeg62-turbo-dev \

libmcrypt-dev \

libpng-dev \

&& docker-php-ext-install -j$(nproc) iconv mcrypt \

&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \

&& docker-php-ext-install -j$(nproc) gd

祝你好运。

以上是 Dockerfile - 运行apt-get install -y php5-MODULES不再工作 - “没有安装应用程序”。如何解决它? 的全部内容, 来源链接: utcz.com/qa/266857.html

回到顶部