You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Docker容器中nodriver无法连接firefox-esr的问题求助

Docker容器中nodriver无法连接firefox-esr的问题求助

我想创建一个Docker镜像,用Python代码实现网站爬取。目前我用x11vnc提供虚拟显示器,firefox-esr作为浏览器,nodriver作为Python爬虫工具。

现在我已经能正常启动容器,并且通过TightVNC看到虚拟显示器,在交互式shell里也能手动启动firefox-esr。但当我用nodriver时,把/usr/bin/firefox-esr作为可执行路径传入,却无法启动浏览器,报错信息如下:


Failed to connect to browser

One of the causes could be when you are running as root.
In that case you need to pass no_sandbox=True

有没有大佬能帮我解决这个问题?


编辑补充:我的Dockerfile内容如下

FROM ubuntu

RUN apt-get update
RUN apt-get install software-properties-common -y
RUN add-apt-repository ppa:mozillateam/ppa

RUN apt-get update && \
    apt-get install -y x11vnc xvfb firefox-esr && \
    mkdir ~/.vnc && \
    touch ~/.vnc/passwd

RUN x11vnc -storepasswd ...

备注:内容来源于stack exchange,提问作者Daniele Lupo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.16 06:58:05