无法通过Docker Build

时间:2017-04-11 18:33:00

标签: php docker dockerfile php-7 gcloud

我遇到了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安装/启用。命令期间没有错误,一目了然,一切似乎都没问题。

查看命令的输出,我可以看到它正在正确下载并尝试安装libzip4ziplibzip4zlib,与php7.0-zip)一起安装的依赖项:

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()会产生以下结果:

enter image description here

在此图片中,未启用zip模块。作为参考,另一个启用了zip的PHP本地安装显示如下:

enter image description here

我尝试按照相同的步骤(php7.0-xsl)安装另一个打包,配置和连接后,xsl模块在​​phpinfo()中显示为已启用:

enter image description here

以前有没有人遇到这个案子?我不知道为什么zip没有安装,我感到茫然......我需要zip模块来处理excel相关功能,但是我不知道下一步该做什么。任何建议都将不胜感激。

如果需要我的整个Dockerfile,我会更新。

1 个答案:

答案 0 :(得分:1)

这是我在Dockerfile上测试的结果,并且可以正常工作:

FROM ubuntu:16.04

RUN apt-get update
RUN apt-get -qq -y install curl
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

运行后:

docker build -t stackoverflow .

docker run -it stackoverflow bash

最后在容器内php -i | grep enabled(执行docker run命令后您将位于的位置)我已经安装并启用了该容器,如您在图像中所见(终端窗口,左下方)

PHP Storm Dockerfile and terminal window

请注意,通常应使用一个RUN命令安装多个扩展,以便仅生成一层。