【发布时间】:2017-04-11 18:32:59
【问题描述】:
我遇到了 Docker 映像的问题。我正在使用基础映像 FROM ubuntu:16.04,并在其上安装以下软件包:
RUN apt-get -y install apache2
RUN apt-get -y install php7.0
RUN apt-get -y install libapache2-mod-php7.0
RUN apt-get -y install php7.0-mysql
RUN apt-get -y install php7.0-gd
RUN apt-get -y install php-pear
RUN apt-get -y install php7.0-curl
RUN apt-get -y install php7.0-mbstrin
RUN apt-get -y install php-imagick
RUN apt-get -y install curl
RUN apt-get -y install lynx-cur
RUN apt-get -y install php7.0-zip
#RUN apt-get -y install php7.0-xsl
长话短说,我需要安装php7.0-zip 包,但使用上述包执行docker build -t [...] . 会导致图像没有安装/启用zip。命令执行过程中没有任何错误,一看就知道一切正常。
查看命令的输出,我可以看到它正在正确下载并尝试安装 libzip4 和 zip(libzip4 或 zlib,是与 @987654339 一起安装的依赖项@):
The following NEW packages will be installed:
libzip4 php7.0-zip
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 56.1 kB of archives.
After this operation, 186 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu xenial/universe amd64 libzip4 amd64 1.0.1-0ubuntu1 [36.3 kB]
Get:2 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 php7.0-zip amd64 7.0.15-0ubuntu0.16.04.4 [19.9 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 56.1 kB in 0s (123 kB/s)
Selecting previously unselected package libzip4:amd64.
(Reading database ... 13491 files and directories currently installed.)
Preparing to unpack .../libzip4_1.0.1-0ubuntu1_amd64.deb ...
Unpacking libzip4:amd64 (1.0.1-0ubuntu1) ...
Selecting previously unselected package php7.0-zip.
Preparing to unpack .../php7.0-zip_7.0.15-0ubuntu0.16.04.4_amd64.deb ...
Unpacking php7.0-zip (7.0.15-0ubuntu0.16.04.4) ...
Processing triggers for libapache2-mod-php7.0 (7.0.15-0ubuntu0.16.04.4) ...
Processing triggers for php7.0-fpm (7.0.15-0ubuntu0.16.04.4) ...
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of restart.
Setting up libzip4:amd64 (1.0.1-0ubuntu1) ...
Setting up php7.0-zip (7.0.15-0ubuntu0.16.04.4) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
Creating config file /etc/php/7.0/mods-available/zip.ini with new version
Processing triggers for libc-bin (2.23-0ubuntu7) ...
Processing triggers for libapache2-mod-php7.0 (7.0.15-0ubuntu0.16.04.4) ...
Processing triggers for php7.0-fpm (7.0.15-0ubuntu0.16.04.4) ...
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of restart.
---> fe12c0bd06fd
Removing intermediate container 7cadeb2256d0
有几个通知,但没有失败。推送到 gcloud 并下载到本地项目后,在配置并连接到映像后运行 phpinfo() 会产生以下结果:
在此图像中,没有启用 zip 模块。作为参考,另一个启用了 zip 的 PHP 本地安装显示如下:
我尝试按照相同的步骤安装另一个包装 (php7.0-xsl),在配置和连接后,xsl 模块在phpinfo() 中显示为启用:
以前有人遇到过这种情况吗?我不知道为什么zip 没有安装,我很茫然......我需要zip 模块来实现excel 相关功能,但我不确定下一步该做什么。任何建议将不胜感激。
如果需要我的整个 Dockerfile,我会更新。
【问题讨论】:
-
你解决了吗?我有同样的问题
-
看看docker-php-ext-install (github.com/docker-library/php/blob/master/…)
-
我也有同样的问题。最好能找到解决方案
-
我尝试使用phpdocker.io,他们的Dockerfile 中确实有zip,当我在docker 图像中尝试
php -i | grep zip时,我确实启用了zip。 (我尝试使用他们网站生成的 docker-compose/Dockerfile。PHP7.0 附带的 Dockerfile 也是 Ubuntu 16) -
抱歉,我的编辑来不及了 :( 这样更容易看到
php -i | grep enabled以防万一,在 docker 映像中打开 bash:docker exec -it yourContainerName-php-fpm /bin/bash
标签: php docker dockerfile php-7 gcloud