Appearance
Docker部署Selenium项目解决PageCrash
在使用 Docker 部署 Selenium 项目出现以下问题
File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 333, in get
self.execute(Command.GET, {'url': url})
File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: session deleted because of page crash
from tab crashed
(Session info: headless chrome=96.0.4664.45)
比较突出的信息为
session deleted because of page crash
from tab crashed
解决方案 1
Simpy mount -v /dev/shm:/dev/shm
解决方案 2
docker run --privileged # 以 privileged 方式启动容器
docker exec $id sudo umount /dev/shm
docker exec $id sudo mount -t tmpfs -o rw,nosuid,nodev,noexec,relatime,size=512M tmpfs /dev/shm