Docker Community Forums

Share and learn in the Docker community.

Rm: cannot remove '/var/lib/apt/lists/': Permission denied


(Coolpilotscorpio) #1

Hi,

I am trying to building new image using docker build command.

I am getting following error message and now im stuck up with this issue. How to fix this problem?

Step 34 : ENV LANG en_US.UTF-8
—> Using cache
—> 7a4069008fc1
Step 35 : ENV RSTUDIO_USER rstudio
—> Using cache
—> 85777351f78d
Step 36 : ENV RSTUDIO_PW rstudio
—> Using cache
—> b36387c40cfc
Step 37 : RUN rm -rf /var/lib/apt/lists/ && apt-get update && apt-get install -t unstable -y --no-install-recommends ca-certificates file git libapparmor1 libedit2 libcurl4-openssl-dev libssl-dev libssl1.0.0 psmisc supervisor python-setuptools sudo && wget -q http://download2.rstudio.org/rstudio-server-${RSTUDIO_VERSION}-amd64.deb && dpkg -i rstudio-server-${RSTUDIO_VERSION}-amd64.deb && rm rstudio-server--amd64.deb && ln -s /usr/lib/rstudio-server/bin/pandoc/pandoc /usr/local/bin && ln -s /usr/lib/rstudio-server/bin/pandoc/pandoc-citeproc /usr/local/bin && apt-get clean && rm -rf /var/lib/apt/lists/
—> Running in 853e29e49570
rm: cannot remove ‘/var/lib/apt/lists/’: Permission denied
The command '/bin/sh -c rm -rf /var/lib/apt/lists/ && apt-get update && apt-get install -t unstable -y --no-install-recommends ca-certificates file git libapparmor1 libedit2 libcurl4-openssl-dev libssl-dev libssl1.0.0 psmisc supervisor python-setuptools sudo && wget -q http://download2.rstudio.org/rstudio-server-${RSTUDIO_VERSION}-amd64.deb && dpkg -i rstudio-server-${RSTUDIO_VERSION}-amd64.deb && rm rstudio-server-
-amd64.deb && ln -s /usr/lib/rstudio-server/bin/pandoc/pandoc /usr/local/bin && ln -s /usr/lib/rstudio-server/bin/pandoc/pandoc-citeproc /usr/local/bin && apt-get clean && rm -rf /var/lib/apt/lists/’ returned a non-zero code: 1
.


(Jeff Anderson) #2

Without a full Dockerfile nor the full output, it’ll be hard to say for sure.

My guess is that you have a USER directive in your Dockerfile above your Step 37 RUN directive that is failing. If the user that you specified doesn’t have permission to run rm -rf /var/lib/apt/lists/, then I would expect the error you are getting.