在Dockerfile中的python镜像上安装google-chrome-stable时出错

ki0zmccv  于 2023-06-19  发布在  Go
关注(0)|答案(2)|浏览(132)

我想在docker中的pyton image上安装google-chrome-stable,但我得到了以下错误:

[7/9] RUN apt-get update && apt-get install -y google-chrome-stable:
#11 1.250 Hit:1 http://deb.debian.org/debian buster InRelease
#11 1.275 Get:2 http://deb.debian.org/debian buster-updates InRelease [51.9 kB]
#11 1.279 Get:3 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
#11 3.055 Get:4 http://security.debian.org/debian-security buster/updates/main amd64 Packages [291 kB]
#11 3.173 Fetched 408 kB in 2s (186 kB/s)
#11 3.173 Reading package lists...
#11 3.850 Reading package lists...
#11 4.502 Building dependency tree...
#11 4.644 Reading state information...
#11 4.751 E: Unable to locate package google-chrome-stable
------
executor failed running [/bin/sh -c apt-get update && apt-get install -y google-chrome-stable]: exit code: 100

我的dockerfile如下:

FROM python:3.8
WORKDIR /test
COPY requirements.txt ./requirements.txt
RUN pip3 install -r requirements.txt
RUN apt-get update && apt-get install -y python3-opencv
RUN pip install opencv-python
RUN apt-get update && apt-get install -y google-chrome-stable

ADD . /app
EXPOSE 8080
COPY . /test
ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=8080", "--server.address=0.0.0.0"]
kognpnkq

kognpnkq1#

根据here的说明,您需要添加chrome repo。因此,将dockerfile更改为如下所示:

FROM python:3.8
WORKDIR /test
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
RUN apt-get update && apt-get install -y google-chrome-stable
j1dl9f46

j1dl9f462#

我在Macbook M1上运行这样的docker镜像(我已经添加了chrome repo)时遇到了相同的错误代码。如果您遇到同样的问题,请修改Dockerfile中的第一行:

FROM --platform=linux/amd64 python:3.8

来源:https://github.com/joyzoursky/docker-python-chromedriver/issues/30

相关问题