Docker 容器中的 Google Chrome:DevToolsActivePort 文件不存在



我有一个Dockerfile,它安装了Google Chrome和chromedriver

FROM python:3.9 AS base
ENV PATH "/opt/venv/bin:$PATH"
ENV PYTHONUNBUFFERED True
ENV PYTHONDONTWRITEBYTECODE True
FROM base as builder
RUN python -m venv /opt/venv
COPY requirements requirements
RUN pip install requests
RUN pip install -r requirements/common.txt
FROM base
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
RUN apt-get install -yqq unzip
RUN wget -qO /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=:1
WORKDIR /app
COPY --from=builder /opt/venv /opt/venv
COPY . .
ARG PORT=5000
ENV PORT $PORT
EXPOSE $PORT
CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 --timeout 0 api:app

它总是有效的,直到今天我得到了错误:

(未知错误:DevToolsActivePort文件不存在((从chrome location/usr/bin/googlechrome开始的过程不再运行,因此ChromeDriver假设chrome已经崩溃。(

chromedriver或谷歌的一些新版本是自己崩溃的吗?

可以是什么?

当DISPLAY为:0时,必须添加选项headless

options.add_argument("--headless")

相关内容

  • 没有找到相关文章

最新更新