简体   繁体   中英

Cannot install Selenium chromedriver in a Docker Container

I'm using this Dockerfile to install Selenium chromedriver in a Docker container:

FROM python:3.8

# install google chrome
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
RUN apt-get -y update
RUN apt-get install -y google-chrome-stable

# install chromedriver
RUN apt-get install -yqq unzip
RUN wget -O /tmp/chromedriver.zip http://chromedriver.storage.googleapis.com/`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`/chromedriver_linux64.zip
RUN unzip /tmp/chromedriver.zip chromedriver -d /usr/local/bin/

ENV DISPLAY=:99

COPY . /app

WORKDIR /app

RUN pip install --upgrade pip

RUN pip install -r requirements.txt

RUN chmod 755 ./run.sh

ENTRYPOINT ["/app/run.sh"]

I already used this Dockerfile some time ago and everything worked fine. Now, I'm getting this error when I run:

docker build -t container .

The error while building:

[+] Building 2.8s (9/17)                                                                                                  
 => [internal] load build definition from Dockerfile                                                                 0.0s
 => => transferring dockerfile: 818B                                                                                 0.0s
 => [internal] load .dockerignore                                                                                    0.0s
 => => transferring context: 2B                                                                                      0.0s
 => [internal] load metadata for docker.io/library/python:3.8                                                        2.1s
 => [ 1/13] FROM docker.io/library/python:3.8@sha256:b9f9612dfd39f75b372056ebb50b9888b4ea7ba48e33d2342f7866816723fa  0.0s
 => [internal] load build context                                                                                    0.0s
 => => transferring context: 46.81kB                                                                                 0.0s
 => CACHED [ 2/13] RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -            0.0s
 => CACHED [ 3/13] RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/ap  0.0s
 => CACHED [ 4/13] RUN apt-get -y update                                                                             0.0s
 => ERROR [ 5/13] RUN apt-get install -y google-chrome-stable                                                        0.7s
------                                                                                                                    
 > [ 5/13] RUN apt-get install -y google-chrome-stable:                                                                   
#8 0.262 Reading package lists...                                                                                         
#8 0.536 Building dependency tree...
#8 0.599 Reading state information...
#8 0.650 E: Unable to locate package google-chrome-stable
------
executor failed running [/bin/sh -c apt-get install -y google-chrome-stable]: exit code: 100
make: *** [build] Error 1

Which is the problem here?

Why not just use an already existing image that does excatly that, as your starting point? For example, this looks like a functional docker image for chrome and python:

https://hub.docker.com/r/joyzoursky/python-chromedriver/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM