I have created a Dockerfile from the apache/zeppelin:0.9.0
base image that installs jq
inside my docker image:
FROM apache/zeppelin:0.9.0
RUN apt-get update && apt-get install -y jq
When I build this image using docker build .
I get the following error message:
[2/2] RUN apt-get update && apt-get install -y jq:
#5 0.257 Reading package lists...
#5 0.272 E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
#5 0.272 E: Unable to lock directory /var/lib/apt/lists/
When using RUN sudo apt-get update && sudo apt-get install -y jq
in my Dockerfile, I run into another error, saying sudo is missing:
[2/2] RUN sudo apt-get update && sudo apt-get install -y jq:
#5 0.249 /bin/sh: 1: sudo: not found
My question is, how can I run apt-get
when using the above Docker base image?
If you look at the zeppelin Dockerfile here, you can see that there's a USER 1000
statement near the end.
When you try to build upon this image, your build steps are run as that user which isn't allowed to install anything.
To fix it, you need to switch to the root user before installing and then back to user 1000 after you're done. Like this
FROM apache/zeppelin:0.9.0
USER root
RUN apt-get update && apt-get install -y jq
USER 1000