我使用这个Dockerfile在Docker容器中安装Selenium chromedriver:
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"]
字符串
我已经用过这个Dockerfile了,一切都很好。现在,当我运行时,我得到这个错误:
docker build -t container .
型
生成时出错:
[+] 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
型
这是什么问题
2条答案
按热度按时间0aydgbwb1#
为什么不使用一个已经存在的图像作为你的起点呢?例如,这看起来像是一个用于chrome和python的功能性docker镜像:
https://hub.docker.com/r/joyzoursky/python-chromedriver/
gzjq41n42#
这是Mac(苹果硅)的解决方案,它可能也适用于其他人
在你的Dockerfile中,通过明确提到linux/amd 6使用
字符串
代替了
型
或
如果您正在使用合成文件,请使用将平台添加到映像
型