I'm trying to build a Dockerfile. But after executing I get this error:

Sending build context to Docker daemon  31.08MB
Step 1/5 : FROM davidrazd/discord-node-10
 ---> 0ad384ff6003
Step 2/5 : RUN apt-get update
 ---> Running in 9fb4313d8011
Reading package lists...
W: chmod 0700 of directory /var/lib/apt/lists/partial failed - SetupAPTPartialDirectory (1: Operation not permitted)
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
The command '/bin/sh -c apt-get update' returned a non-zero code: 100

I also tried to put sudo in the dockerfile to make sure I have full access as root.


# Start writing your Dockerfile easily
FROM davidrazd/discord-node-10

RUN sudo apt-get update
RUN sudo apt-get install -y python-pip
RUN sudo install --upgrade pip

The image you imported includes a user specification:

USER container

The apt-get update and apt-get install command require root access. Within a docker build, you get root access by running your container commands as root, rather than performing a sudo. Therefore, your dockerfile would look like:

# Start writing your Dockerfile easily
FROM davidrazd/discord-node-10
USER root
RUN apt-get update \
 && apt-get install -y python-pip \
 && install --upgrade pip
USER container

I'd recommend reading the following before getting much further into writing your Dockerfiles since there are other issues you'll want to resolve with the apt-get commands (chaining commands, removing input from config, not installing recommended packages, and cleaning up after the install commands): https://docs.docker.com/develop/develop-images/dockerfile_best-practices/

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.