如何从 Ubuntu 22.04 中的 docker 容器启动图形程序

问题描述 投票:0回答:1

我遵循以下步骤:

nano Dockerfile
   FROM UBUNTU:22.10
   RUN apt-get update && apt-get install -y firefox
   CMD /usr/bin/firefox

docker build -t firefox .

xhost +

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,但我无法获得正确的配置:

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

问题的另一个原因可能是 /tmp/.X11-unix:/tmp/.X11-unix 是 Ubuntu 22.04 中的另一条路线。

docker ubuntu graphics operating-system
1个回答
0
投票

According to this thread, it's possible to install firefox without snap.

这是在 Dockerfile 中使用 firefox-esr 的最简单的解决方案:

FROM ubuntu:22.10
RUN  apt update -yq \
     && apt install -yq software-properties-common \
     && add-apt-repository ppa:mozillateam/ppa \
     && apt-get update \
     && apt-get install -y firefox-esr \
     && rm -rf /var/lib/apt/lists/*
CMD /usr/bin/firefox-esr
© www.soinside.com 2019 - 2024. All rights reserved.