Newer
Older
glx-docker-headless-gpu / Dockerfile
@Ryo Nakabayashi Ryo Nakabayashi on 4 Dec 2019 3 KB fix for AWS g4dn.2xlarge
  1. FROM ubuntu:16.04
  2.  
  3. # Make all NVIDIA GPUS visible, but I want to manually install drivers
  4. ARG NVIDIA_VISIBLE_DEVICES=all
  5. # Supress interactive menu while installing keyboard-configuration
  6. ARG DEBIAN_FRONTEND=noninteractive
  7.  
  8.  
  9. # (1) Install Xorg and NVIDIA driver inside the container
  10. # Almost same procesure as nvidia/driver https://gitlab.com/nvidia/driver/blob/master/ubuntu16.04/Dockerfile
  11.  
  12. # (1-1) Install prerequisites
  13. RUN dpkg --add-architecture i386 && \
  14. apt-get update && apt-get install -y --no-install-recommends \
  15. apt-utils \
  16. build-essential \
  17. ca-certificates \
  18. curl \
  19. wget \
  20. vim \
  21. zip \
  22. unzip \
  23. git \
  24. python \
  25. kmod \
  26. libc6:i386 \
  27. pkg-config \
  28. libelf-dev && \
  29. rm -rf /var/lib/apt/lists/*
  30.  
  31. # (1-2) Install xorg server and xinit BEFORE INSTALLING NVIDIA DRIVER.
  32. # After this installation, command Xorg and xinit can be used in the container
  33. RUN apt-get update && apt-get install -y \
  34. xinit && \
  35. rm -rf /var/lib/apt/lists/*
  36.  
  37. # (1-3) Install NVIDIA drivers, including X graphic drivers
  38. # Same command as nvidia/driver, except --x-{prefix,module-path,library-path,sysconfig-path} are omitted in order to make use default path and enable X drivers.
  39. # Driver version must be equal to host's driver
  40. # Install the userspace components and copy the kernel module sources.
  41. ENV DRIVER_VERSION=418.87.01
  42. RUN cd /tmp && \
  43. curl -fSsl -O https://us.download.nvidia.com/tesla/418.87/NVIDIA-Linux-x86_64-418.87.01.run && \
  44. sh NVIDIA-Linux-x86_64-$DRIVER_VERSION.run -x && \
  45. cd NVIDIA-Linux-x86_64-$DRIVER_VERSION* && \
  46. ./nvidia-installer --silent \
  47. --no-kernel-module \
  48. --install-compat32-libs \
  49. --no-nouveau-check \
  50. --no-nvidia-modprobe \
  51. --no-rpms \
  52. --no-backup \
  53. --no-check-for-alternate-installs \
  54. --no-libglx-indirect \
  55. --no-glvnd-egl-client \
  56. --no-glvnd-glx-client \
  57. --no-install-libglvnd && \
  58. mkdir -p /usr/src/nvidia-$DRIVER_VERSION && \
  59. mv LICENSE mkprecompiled kernel /usr/src/nvidia-$DRIVER_VERSION && \
  60. sed '9,${/^\(kernel\|LICENSE\)/!d}' .manifest > /usr/src/nvidia-$DRIVER_VERSION/.manifest && \
  61. rm -rf /tmp/*
  62. # this option cannot be used on newer driver
  63. # --no-glvnd-egl-client \
  64. # --no-glvnd-glx-client \
  65.  
  66. # (2) Configurate Xorg
  67. # (2-1) Install some necessary softwares
  68. #
  69. # pkg-config: nvidia-xconfig requires this package
  70. # mesa-utils: This package includes glxgears and glxinfo, which is useful for testing GLX drivers
  71. # x11vnc: Make connection between x11 server and VNC client.
  72. # x11-apps: xeyes can be used to make sure that X11 server is running.
  73. #
  74. RUN apt-get update && apt-get install -y --no-install-recommends \
  75. mesa-utils \
  76. x11vnc \
  77. x11-apps && \
  78. rm -rf /var/lib/apt/lists/*
  79.  
  80. # (2-2) Optional vulkan support
  81. # vulkan-utils includes vulkan-smoketest, benchmark software of vulkan API
  82. RUN apt-get update && apt-get install -y --no-install-recommends \
  83. libvulkan1 vulkan-utils && \
  84. rm -rf /var/lib/apt/lists/*
  85.  
  86. # for test
  87. RUN apt-get update && apt-get install -y --no-install-recommends \
  88. firefox openbox && \
  89. rm -rf /var/lib/apt/lists/*
  90.  
  91. # sound driver and GTK library
  92. # ALSA系のエラーがでる時は、pulseaudioをインストールして
  93. # X起動後にpulseaudio --start でdaemonを開始させる。
  94. RUN apt-get update && apt-get install -y --no-install-recommends \
  95. alsa pulseaudio libgtk2.0-0 && \
  96. rm -rf /var/lib/apt/lists/*
  97.  
  98. # novnc
  99. RUN wget https://github.com/novnc/noVNC/archive/v1.1.0.zip && \
  100. unzip -q v1.1.0.zip && \
  101. rm -rf v1.1.0.zip
  102.  
  103. # (3) Run Xorg server + x11vnc + X applications
  104. # see run.sh for details
  105. COPY run.sh /run.sh
  106. CMD ["bash", "/run.sh"]