diff --git a/ubuntuWithNvidiaDriver/Dockerfile b/ubuntuWithNvidiaDriver/Dockerfile index 1790e4f..dac187d 100644 --- a/ubuntuWithNvidiaDriver/Dockerfile +++ b/ubuntuWithNvidiaDriver/Dockerfile @@ -1,11 +1,62 @@ -FROM ubuntu -MAINTAINER github/gklingler +FROM ubuntu:16.04 +MAINTAINER github/ElCoyote27 + +ENV http_proxy "http://imladris.lasthome.solace.krynn:3128" +ENV ftp_proxy "http://imladris.lasthome.solace.krynn:3128" +ENV https_proxy "http://imladris.lasthome.solace.krynn:3128" +ENV no_proxy "localhost.localdomain,localhost,127.0.0.1,.localdomain4,localhost4,.localdomain6,localhost6,.lasthome.solace.krynn" + +# Workaround for issues with mirrors.. +# RUN echo 'options ndots:2 timeout:2 attempts:2 single-request' >> /etc/resolv.conf +RUN echo 'Acquire::http::Proxy "http://imladris.lasthome.solace.krynn:3128";' >> /etc/apt/apt.conf.d/01-vendor-ubuntu +# RUN sed -i s/http/ftp/ /etc/apt/sources.list RUN apt-get update RUN apt-get install -y mesa-utils +RUN apt-get install -y sudo binutils less x11-apps kmod apt-utils python python-tk pkg-config nano iproute wget +RUN apt-get update + +RUN apt-get install -y rss-glx + + +# Google Chrome +WORKDIR /tmp +#RUN apt-get install -y libxss1 libappindicator1 libindicator7 +RUN wget -qO google-chrome-stable_current_amd64.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb +ADD google-chrome-stable_current_amd64.deb /tmp/google-chrome-stable_current_amd64.deb +RUN apt-get update +#RUN sudo dpkg -i /tmp/google-chrome-stable_current_amd64.deb +RUN sudo apt-get install -y /tmp/google-chrome-stable_current_amd64.deb + # install nvidia driver -RUN apt-get install -y binutils ADD NVIDIA-DRIVER.run /tmp/NVIDIA-DRIVER.run -RUN sh /tmp/NVIDIA-DRIVER.run -a -N --ui=none --no-kernel-module +# Run NVidia driver install +RUN sh /tmp/NVIDIA-DRIVER.run -s -N --ui=none --no-kernel-module RUN rm /tmp/NVIDIA-DRIVER.run + +# Add 'worker' user +RUN adduser --disabled-password --gecos 'Runtime user' worker +RUN adduser worker sudo +RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers + +# allow the worker user to access video devices +RUN usermod -a -G video worker + +WORKDIR /home/worker +# are taken from GNU su manual +ENV HOME /home/worker +ENV SHELL /bin/bash +ENV USER worker +ENV LOGNAME worker +ENV LANG en_US.UTF-8 +ENV LC_ALL en_US.UTF-8 + +# This helps not forgetting setting DISPLAY=:0 when running +# tests outside of test.sh +#ENV DISPLAY :0 + +USER worker + +# Set a default command useful for debugging +CMD ["/bin/bash", "--login"] diff --git a/ubuntuWithNvidiaDriver/build.sh b/ubuntuWithNvidiaDriver/build.sh index b80b939..62e042a 100755 --- a/ubuntuWithNvidiaDriver/build.sh +++ b/ubuntuWithNvidiaDriver/build.sh @@ -1,7 +1,14 @@ #!/bin/sh -IMAGE_NAME=ubuntu_with_nvidia_driver -NVIDIA_DRIVER=NVIDIA-Linux-x86_64-337.12.run # path to nvidia driver - -cp ${NVIDIA_DRIVER} NVIDIA-DRIVER.run -sudo docker build -t ${IMAGE_NAME} . +IMAGE_NAME=docker3d +NVIDIA_VERSION=$(/sbin/modinfo -F version nvidia) +# path to nvidia driver +NVIDIA_DRIVER=NVIDIA-Linux-x86_64-${NVIDIA_VERSION}.run +if [ -f ${NVIDIA_DRIVER} ]; then + echo "Using existing ${NVIDIA_DRIVER}..." +else + wget -O ${NVIDIA_DRIVER} http://us.download.nvidia.com/XFree86/Linux-x86_64/${NVIDIA_VERSION}/${NVIDIA_DRIVER} || exit 127 +fi +/bin/cp -f ${NVIDIA_DRIVER} NVIDIA-DRIVER.run +######sudo docker build -t ${IMAGE_NAME} . +docker build -t ${IMAGE_NAME} . diff --git a/ubuntuWithNvidiaDriver/run.sh b/ubuntuWithNvidiaDriver/run.sh index 9fec378..6ffabac 100755 --- a/ubuntuWithNvidiaDriver/run.sh +++ b/ubuntuWithNvidiaDriver/run.sh @@ -2,5 +2,17 @@ COMMAND=/bin/bash -xhost + # allow connections to X server -docker run --privileged -e "DISPLAY=unix:0.0" -v="/tmp/.X11-unix:/tmp/.X11-unix:rw" -i -t ubuntu_with_nvidia_driver $COMMAND +if [ "x${DISPLAY}" = "x" ]; then + docker run --privileged \ + -v="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ + -v="/var/tmp:/var/tmp:rw" \ + -i -t -u worker docker3d +else + #xhost + # allow connections to X server + xhost local:root + docker run --privileged --rm \ + -e "DISPLAY=unix:$(echo ${DISPLAY}|cut -d: -f2)" \ + -v="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ + -v="/var/tmp:/var/tmp:rw" \ + -i -t -u worker docker3d +fi