Docker构建结束时出现错误“命令...返回非零代码:100”

时间:2016-09-21 18:10:35

标签: docker dockerfile docker-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

更新

我删除了所有图片&amp;容器并使用--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

这对错误有意义,问题是为什么?

1 个答案:

答案 0 :(得分:2)

我已经使用docker run -it ubuntu:12.04手动完成了你的Dockerfile并完成了这些步骤(顺便说一句,这是一个很好的提示,当你把一张复杂的图像放在一起时)。

apt-get命令对我来说都很好。您的错误与ssl-cert安装有关,因此您的构建在第一个RUN指令上失败,其余的Dockerfile将不会被处理。

建造时可能是临时问题?您是再次尝试过还是在其他主机上尝试过?