我正在尝试创建一个 Docker 映像,该映像使用 NVIDIA GPU 为 OpenGL 无头应用程序运行 X 服务器。(可用于创建纹理、在没有屏幕的情况下运行 Unity3D 等)。在这种情况下,主机不运行 X 服务器,我想在容器内完成所有操作。
我正在使用这个 Dockerfile 作为图像:
FROM ubuntu:18.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && \
apt install -y \
libglvnd0 \
libgl1 \
libglx0 \
libegl1 \
libgles2 \
xserver-xorg-video-nvidia-440
COPY xorg.conf.nvidia-headless /etc/X11/xorg.conf
ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES graphics
ENV DISPLAY :1
ENTRYPOINT ["/bin/bash"]
Run Code Online (Sandbox Code Playgroud)
对于 xorg.config.nvidia-headless 我用 nvidia-xconfig 创建了它
Section "ServerLayout"
Identifier "Layout0"
Screen 0 "Screen0"
EndSection
Section "Files"
EndSection
Section "Module"
Load "dbe"
Load "extmod"
Load "type1"
Load …Run Code Online (Sandbox Code Playgroud)