Ubuntu 22.04下从Docker容器启动Firefox图形程序失败的问题求助
Ubuntu 22.04下从Docker容器启动Firefox图形程序失败的问题求助
各位大佬好,我最近在折腾用Docker在Ubuntu 22.04上启动Firefox的图形界面版本,试了好几次都没成功,想请教下大家有没有解决办法。
我最开始的操作步骤是这样的:
- 用
nano Dockerfile创建了一个Dockerfile,内容如下:
FROM UBUNTU:22.10 RUN apt-get update && apt-get install -y firefox CMD /usr/bin/firefox
- 执行镜像构建命令:
docker build -t firefox . - 运行
xhost +来授权容器访问本地的X11显示 - 启动容器:
docker run -d --name firefox -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix firefox
结果容器启动后,我用docker logs firefox查看日志,得到了这样的报错:
Command '/usr/bin/firefox' requires the firefox snap to be installed.
Please install it with:
snap install firefox
之后我尝试修改了Dockerfile,改成了下面的配置,但还是没能成功启动Firefox:
FROM ubuntu:22.04 ENV container docker RUN apt-get update && apt-get install -y systemd systemd-sysv RUN apt-get install -y snapd RUN systemctl enable --now snapd.socket RUN snap wait system seed.loaded RUN snap install firefox CMD /usr/bin/firefox
我现在怀疑会不会是Ubuntu 22.04里/tmp/.X11-unix的路径和之前版本不一样,导致X11转发出了问题?或者还有其他我没考虑到的配置问题吗?麻烦大家帮忙看看,谢谢了!
备注:内容来源于stack exchange,提问作者Totocode
相关产品推荐
相关产品推荐

