2

我试图使用现有的 Dockerfile 构建一个新图像。看起来它确实在某个时候从缓存中恢复了。但是构建并没有从非常简单的步骤(如 apt 安装/更新)演变而来。如何获得有关实际错误以及如何从该状态恢复的更多信息?非常感谢!

...
Step 15 : RUN apt-get install -y cron
 ---> Using cache
 ---> a2a6dea37a20
Step 16 : RUN apt-get install -y vim
 ---> Using cache
 ---> a2a5dea37a19
Step 17 : RUN apt-get install -y debsecan
 ---> Using cache
 ---> cc2aa4c994c2
Step 18 : RUN apt-get install -y links
 ---> Using cache
 ---> abb32d4543f6
Step 19 : RUN apt-get update
 ---> Running in 68c12197bcfd
Cannot start container 68c12197bcfd12f39e669dc4ba1f1dc07a6fde07c675b6e763...: [9] System error: exit status 1

码头工人版本

Client:
 Version:         1.10.3
 API version:     1.22
 Package version: docker-common-1.10.3-46.el7.14.x86_64
 Go version:      go1.6.3
 Git commit:      8f9d39a-unsupported
 Built:           Thu Sep 15 11:51:19 2016
 OS/Arch:         linux/amd64

Server:
 Version:         1.10.3
 API version:     1.22
 Package version: docker-common-1.10.3-46.el7.14.x86_64
 Go version:      go1.6.3
 Git commit:      8f9d39a-unsupported
 Built:           Thu Sep 15 11:51:19 2016
 OS/Arch:         linux/amd64



FROM debian:latest

MAINTAINER me@example.com

RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get update
RUN apt-get install -y sudo
RUN apt-get install -y dialog
RUN apt-get install -y curl
RUN apt-get install -y wget
RUN apt-get install -y vim
RUN apt-get install -y net-tools
RUN apt-get install -y apt-utils
RUN apt-get install -y net-tools
RUN apt-get install -y cron
RUN apt-get install -y vim
RUN apt-get install -y debsecan
RUN apt-get install -y links
RUN apt-get update
RUN apt-get install -y apache2
RUN cd /var/www && mv html htmlapache
RUN mkdir -p /var/www/html/repo
RUN touch /var/www/html/index.html
COPY entrypoint.sh /
RUN apt-get -y install salt-master
CMD [ "/entrypoint.sh" ]
EXPOSE 8000
4

1 回答 1

1

您无需apt-get update多次调用。在一行中更新和安装所有包也是一个好习惯,因为它只在 docker 映像中创建一个层

FROM debian:latest

MAINTAINER me@example.com

RUN apt-get update \
    && upgrade -y \
    && apt-get install -y sudo dialog curl wget vim net-tools apt-utils net-tools cron vim debsecan links apache2 salt-master
RUN cd /var/www && mv html htmlapache
RUN mkdir -p /var/www/html/repo
RUN touch /var/www/html/index.html
COPY entrypoint.sh /
CMD [ "/entrypoint.sh" ]
EXPOSE 8000
于 2016-12-02T15:04:22.950 回答