Docker构build结束,错误“命令…返回一个非零代码:100”

我正在构build一个Docker镜像, Dockerfile如下所示:

 FROM ubuntu:12.04 MAINTAINER Maintainer Name <my_address@goes.here> VOLUME ["/var/www"] RUN apt-get update && \ apt-get install -y \ apache2 \ php5 \ php5-cli \ libapache2-mod-php5 \ php5-gd \ php5-ldap \ php5-mysql COPY apache_default /etc/apache2/sites-available/default COPY run /usr/local/bin/run RUN chmod +x /usr/local/bin/run RUN a2enmod rewrite EXPOSE 80 CMD ["/usr/local/bin/run"] 

运行文件包含以下代码:

 #!/bin/bash set -e PHP_ERROR_REPORTING=${PHP_ERROR_REPORTING:-"E_ALL & ~E_DEPRECATED & ~E_NOTICE"} sed -ri 's/^display_errors\s*=\s*Off/display_errors = On/g' /etc/php5/apache2/php.ini sed -ri 's/^display_errors\s*=\s*Off/display_errors = On/g' /etc/php5/cli/php.ini sed -ri "s/^error_reporting\s*=.*$//g" /etc/php5/apache2/php.ini sed -ri "s/^error_reporting\s*=.*$//g" /etc/php5/cli/php.ini echo "error_reporting = $PHP_ERROR_REPORTING" >> /etc/php5/apache2/php.ini echo "error_reporting = $PHP_ERROR_REPORTING" >> /etc/php5/cli/php.ini source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND 

我看到一些错误输出到控制台,当我运行命令:

 docker build -t dev-image . 

标有---的行(这只是为了显示行,并不意味着输出有这样的符号)最后在控制台中标记为红色:

 ... Get:69 http://archive.ubuntu.com/ubuntu/ precise-updates/main ssl-cert all 1.0.28ubuntu0.1 [12.3 kB] debconf: delaying package configuration, since apt-utils is not installed --- Fetched 26.7 MB in 48s (550 kB/s) ... Unpacking ucf (from .../ucf_3.0025+nmu2ubuntu1_all.deb) ... Moving old data out of the way --- Selecting previously unselected package ttf-dejavu-core ... Setting up ucf (3.0025+nmu2ubuntu1) ... debconf: unable to initialize frontend: Dialog --- debconf: (TERM is not set, so the dialog frontend is not usable.) --- debconf: falling back to frontend: Readline --- debconf: unable to initialize frontend: Readline --- debconf: (This frontend requires a controlling tty.) --- debconf: falling back to frontend: Teletype --- Setting up ttf-dejavu-core (2.33-2ubuntu1) ... ... Setting up php5-cli (5.3.10-1ubuntu3.24) ... debconf: unable to initialize frontend: Dialog --- debconf: (TERM is not set, so the dialog frontend is not usable.) --- debconf: falling back to frontend: Readline --- debconf: unable to initialize frontend: Readline --- debconf: (This frontend requires a controlling tty.) --- debconf: falling back to frontend: Teletype --- Creating config file /etc/php5/cli/php.ini with new version --- update-alternatives: using /usr/bin/php5 to provide /usr/bin/php (php) in auto mode. ... Setting up apache2-mpm-prefork (2.2.22-1ubuntu1.11) ... invoke-rc.d: policy-rc.d denied execution of start. --- Setting up apache2 (2.2.22-1ubuntu1.11) ... ... ldconfig deferred processing now taking place Errors were encountered while processing: ssl-cert E: Sub-process /usr/bin/dpkg returned an error code (1) The command '/bin/sh -c apt-get update && apt-get install -y apache2 php5 php5-cli libapache2-mod-php5 php5-gd php5-ldap php5-mysql' returned a non-zero code: 100 

为什么? 我在这里没有注意到什么? 我错过了什么?

我在Fedora 24中运行Docker 1.10.3:

 $ docker -v Docker version 1.10.3, build a612434/1.10.3 

UPDATE

我删除了所有的图像和容器后,使用--no-cache运行一个干净的版本,现在我可以看到这个错误:

 Setting up ssl-cert (1.0.28ubuntu0.1) ... debconf: unable to initialize frontend: Dialog debconf: (TERM is not set, so the dialog frontend is not usable.) debconf: falling back to frontend: Readline debconf: unable to initialize frontend: Readline debconf: (This frontend requires a controlling tty.) debconf: falling back to frontend: Teletype groupadd: failure while writing changes to /etc/group addgroup: `/usr/sbin/groupadd -g 102 ssl-cert' returned error code 10. Exiting. dpkg: error processing ssl-cert (--configure): subprocess installed post-installation script returned error exit status 1 

这与错误是有道理的,问题是为什么?

我已经通过docker docker run -it ubuntu:12.04 -it docker run -it ubuntu:12.04手动进入了你的Dockerfile,并且经历了这些步骤(顺便提一下,当你把一个复杂的图像放在一起的时候,这是一个很好的提示)。

apt-get命令对我来说都很好。 你的错误是关于ssl-cert安装的,所以你的编译在第一个RUN指令上失败了,其余的Dockerfile将不会被处理。

当你build造时可能是暂时的问题? 你有没有尝试过或在不同的主机上?