docker build error (apt-utils is not installed, cannot remove '/var/lib/apt/lists': Directory not empty)
13,412
A few comments:
Do not remove those files. Just run
apt-get update
again. I'm part of the Rocker project of (official) Dockerfiles for R, and we do see these timeouts. They are harmless.If you insist (and I still recommend against) do
rm /var/lib/apt/lists/*
for the content within the directory.As for
apt-utils
missing, you could just install it.
Author by
Radu Artene
Updated on July 18, 2022Comments
-
Radu Artene almost 2 years
I'm trying to build a docker image using the following command
docker build -t blog .
and the 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
the result I get is the following:
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
what is red are the 2 lines:
debconf: delaying package configuration, since apt-utils is not installed rm: cannot remove '/var/lib/apt/lists': Directory not empty
Why it cannot remove the directory since I'm using -rf?
Thank you!
-
Nanne over 7 yearsAs I read it, the command is
rm -rf /var/lib/apt/lists
, so you rfirst bullet seems strange? -
Dirk Eddelbuettel over 7 yearsNo that is the same thing. On a directory, without
-r
, you get the error the OP got. With-r
added torm -r
it works. The-f
just "forces". -
Nanne over 7 yearsI might be really thick, but I really don't get you. The OP uses
-rf
. I know that-f
means force, but the fact it says-rf
means the OP (also) uses-r
. So saying "with-r
added it works", doesn't help: OP says they use-rf
, which means that-r
is supplied. -
Dirk Eddelbuettel over 7 yearsYep. My bad. He does. I still recommend against (it will upset
apt
and friends) but hey, his Dockerfile.... Thanks for catching that. Answer edited. -
Radu Artene over 7 yearsI removed the "rm -rf /var/lib/apt/lists" line. It executes now. I'm still not clear although on why it does not work since -rf means recursive force. Thank you for your help.