I want to create a docker image with selenium and chrome correctly installed, so I choose a base image with these properties. Therefore, the first line of the Dockerfile is as follows:
FROM selenium/node-chrome:3.7.1-argon Then the next command is
RUN apt-get update which created the following error while creating the docker image:
Step 4/19 : RUN apt-get update ---> Running in af08ae07cbf3 Reading package lists... E: List directory /var/lib/apt/lists/partial is missing. - Acquire (13: Permission denied) The command '/bin/sh -c apt-get update' returned a non-zero code: 100 How to be able to install python in this docker image?
2 Answers
RUN sudo apt-get update -y
RUN sudo apt-get install -y python
As hinted by:
Acquire (13: Permission denied)
I believe this is due to your base image:
As you can see it swaps from the default user context of 'root' to 'seluser'.
You can either:
- wear this as a consequence of the base image (i.e. use sudo)
- swap back:
USER root - or consider creating your own docker image to avoid swapping in the first place
Using sudo is best avoided in Dockerfiles where possible, so it would be preferable to go with option #2 or #3, rather than #1.
Hope that helps mate.
7Note: Below commands may require root/administrative previleges.
- Download docker image
docker pull ubuntu - Start interactive container
docker run -it ubuntu /bin/bash
Note: By default you will be logged in inside container as root user if not then either elevate your privileges to root or use sudo before below listed commands
- Update container instance
apt-get update - For python 2.7
apt-get install python2 - For Python 3.x
apt-get install python3