Dockerfile ADD指令无法添加文件

我遇到了这个问题。我正在通过以下 Dockerfile 构建 Docker 图像

#
# Nginx 自定义域名 Https Dockerfile
#
# 构建具有自动 SSL 功能的 OpenResty nginx 图像
# 参考: https://github.com/GUI/lua-resty-auto-ssl
#

FROM openresty/openresty:latest-xenial

RUN apt-get update
RUN apt-get install -y apt-transport-https
RUN apt-get install -y --no-install-recommends apt-utils
RUN echo "license_key: 64553f3xxxxxxxxx" | tee -a /etc/newrelic-infra.yml

RUN curl https://download.newrelic.com/infrastructure_agent/gpg/newrelic-infra.gpg | apt-key add -
RUN printf "deb [arch=amd64] https://download.newrelic.com/infrastructure_agent/linux/apt xenial main" | tee -a /etc/apt/sources.list.d/newrelic-infra.list
RUN cat /etc/apt/sources.list.d/newrelic-infra.list
RUN echo "license_key: 64553fxxxxxxxxxxxx" | tee -a /etc/newrelic-infra.yml
RUN cat /etc/newrelic-infra.yml
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -yq newrelic-infra

....

还有更多,请继续查看以下问题

我通过以下方式运行它

docker build -t XXXXXXXXXX.dkr.ecr.us-west-2.amazonaws.com/qwilr-codebuild-base:latest .

其输出为:

  Sending build context to Docker daemon  41.47kB
    Step

 1/19 : FROM openresty/openresty:latest-xenial
    ....
Step 9/19 : RUN echo "license_key: 64553f38xxxxxxxx" | tee
-a /etc/newrelic-infra.yml
 ---> Using cache
 ---> 77cd0ece8528
Step 10/19 : RUN cat /etc/newrelic-infra.yml
 ---> Using cache
 ---> 2cb1a27b4d8b
Get:1 https://download.newrelic.com/infrastructure_agent/linux/apt xenial/main amd64 newrelic-infra amd64 1.2.15 [4679 kB]
Fetched 4679 kB in 14s (325 kB/s)
Selecting previously unselected package newrelic-infra.
(Reading database ... 15601 files and directories currently installed.)
Preparing to unpack .../newrelic-infra_1.2.15_amd64.deb ...
Unpacking newrelic-infra (1.2.15) ...
Setting up newrelic-infra (1.2.15) ...
Failed to connect to bus: No such file or directory
dpkg: error processing package newrelic-infra (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 newrelic-infra
E: Sub-process /usr/bin/dpkg returned an error code (1)
The command '/bin/sh -c DEBIAN_FRONTEND=noninteractive apt-get install -yq newrelic-infra' returned a non-zero code: 100

问题似乎在于添加了 newrelic-infra.yml 文件却无法正常工作。我还尝试使用 COPY 和 ADD,但仍然无法正常工作。是否有我忽略的一些内容,使得该文件无法出现在接下来的 apt-get install 命令中?

我也使用了 --no-cache 参数运行了一遍,仍然出现相同的错误。我相信关键的失败原因是 newrelic-infra 的安装需要文件 /etc/newrelic-infra.yml,正如 Failed to connect to bus: No such file or directory 所标明的那样。

为什么添加到 /etc/ 目录下的文件会失败呢?是我使用的基础镜像出了问题吗?

点赞
用户2176812
用户2176812

看起来这是一个开放的问题。

dpkg error processing package newrelic-infra

此外,该软件包在linux/apt中失踪了。

2019-03-19 11:00:55