我正在嘗試在 Google Cloudrun 上部署我的抓取工具,但是出現(xiàn)以下錯(cuò)誤。selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.at check_response (/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py:242)at execute (/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py:321)at start_session (/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py:252)at __init__ (/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py:157)at __init__ (/usr/local/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py:76)at scrape_refresher (/app/refresher_news_crawler.py:32)at run_crawlers (/app/main.py:30)at dispatch_request (/usr/local/lib/python3.8/site-packages/flask/app.py:1936)at full_dispatch_request (/usr/local/lib/python3.8/site-packages/flask/app.py:1950)at reraise (/usr/local/lib/python3.8/site-packages/flask/_compat.py:39)at handle_user_exception (/usr/local/lib/python3.8/site-packages/flask/app.py:1821)at wrapped_function (/usr/local/lib/python3.8/site-packages/flask_cors/extension.py:165)at full_dispatch_request (/usr/local/lib/python3.8/site-packages/flask/app.py:1952)at wsgi_app (/usr/local/lib/python3.8/site-packages/flask/app.py:2447)我假設(shè)這將是版本不匹配,但由于我的 docker 文件正在下載最新的穩(wěn)定版本85.0.4183.83,即使在將其與chromedriver-binary==85.0.4183.83.0 錯(cuò)誤不斷發(fā)生之后,我也嘗試了最新版本的 chromdriver-binary,但85.0.4183.87.0結(jié)果是相同。Docker 文件:# Use the official lightweight Python image.# https://hub.docker.com/_/pythonFROM python:3.8-slim# Install manually all the missing librariesRUN apt-get updateRUN apt-get install -y gconf-service wget libasound2 libgbm1 libappindicator3-1 libatk1.0-0 libcairo2 libcups2 libfontconfig1 libgdk-pixbuf2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libxss1 fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils安裝過程中沒有問題,只有運(yùn)行過程中出現(xiàn)問題。任何幫助深表感謝。
1 回答

拉風(fēng)的咖菲貓
TA貢獻(xiàn)1995條經(jīng)驗(yàn) 獲得超2個(gè)贊
您是否以 root 身份運(yùn)行驅(qū)動(dòng)程序?如果是這樣,請(qǐng)嘗試使用該--no-sandbox
選項(xiàng)作為驅(qū)動(dòng)程序的第一個(gè)參數(shù)。盡管由于存在漏洞,我建議不要以 root 身份運(yùn)行它。
我從您的評(píng)論中看到,這解決了問題,但如果安全性對(duì)您的情況確實(shí)很重要,我建議您創(chuàng)建一個(gè)非 root 用戶來運(yùn)行您的服務(wù)。
添加回答
舉報(bào)
0/150
提交
取消