docker build error(未安装apt-utils,无法删除'/ var / lib / apt / lists':目录不为空)

时间:2017-02-10 12:50:25

标签: linux docker

我正在尝试使用以下命令构建一个泊坞窗图像

docker build -t blog .

和Dockerfile:

FROM ruby:2.4


RUN apt-get update -yqq \
    && apt-get install -yqq --no-install-recommends \
      postgresql-client \
      && rm -rf /var/lib/apt/lists


WORKDIR /usr/src/app
COPY Gemfile* .
RUN bundle install
COPY . .

EXPOSE 3000
CMD rails server -b 0.0.0.0

我得到的结果如下:

Step 1 : FROM ruby:2.4
 ---> ef296fcb8c7c
Step 2 : RUN apt-get update -yqq     && apt-get install -yqq --no-install-recommends       postgresql-client       && rm -rf /var/lib/apt/lists
 ---> Running in 18bfd303925d
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package postgresql-client-common.
(Reading database ... 21168 files and directories currently installed.)
Preparing to unpack .../postgresql-client-common_165+deb8u2_all.deb ...
Unpacking postgresql-client-common (165+deb8u2) ...
Selecting previously unselected package postgresql-client-9.4.
Preparing to unpack .../postgresql-client-9.4_9.4.10-0+deb8u1_amd64.deb ...
Unpacking postgresql-client-9.4 (9.4.10-0+deb8u1) ...
Selecting previously unselected package postgresql-client.
Preparing to unpack .../postgresql-client_9.4+165+deb8u2_all.deb ...
Unpacking postgresql-client (9.4+165+deb8u2) ...
Setting up postgresql-client-common (165+deb8u2) ...
Setting up postgresql-client-9.4 (9.4.10-0+deb8u1) ...
update-alternatives: using /usr/share/postgresql/9.4/man/man1/psql.1.gz to provide /usr/share/man/man1/psql.1.gz (psql.1.gz) in auto mode
Setting up postgresql-client (9.4+165+deb8u2) ...
rm: cannot remove '/var/lib/apt/lists': Directory not empty
The command '/bin/sh -c apt-get update -yqq     && apt-get install -yqq --no-install-recommends       postgresql-client       && rm -rf /var/lib/apt/lists' returned a non-zero code: 1

红色是2行:

debconf: delaying package configuration, since apt-utils is not installed

rm: cannot remove '/var/lib/apt/lists': Directory not empty

为什么它不能删除目录,因为我正在使用-rf?

谢谢!

1 个答案:

答案 0 :(得分:2)

一些评论:

  • 请勿删除这些文件。只需再次运行apt-get update即可。我是R(官方)Dockerfiles Rocker project的一部分,我们确实看到了这些超时。它们是无害的。

  • 如果您坚持(我仍然建议您反对),请对目录中的内容执行rm /var/lib/apt/lists/*

  • 至于apt-utils缺失,您可以安装它。