554
FROM centos:centos6
MAINTAINER Alex
# Install the appropriate software
RUN yum -y update && yum -y groupinstall "Desktop" "X Window System" "Fonts"
RUN yum -y install epel-release wget gedit file-roller gnome-system-monitor nautilus-open-terminal \
samba-client samba-common unzip firefox git nano htop python-setuptools && \
yum clean all && rm -rf /tmp/*
# Variables
ENV ROOT_PASSWD centos
ENV USER_PASSWD password
# VNC & XRDP Servers
RUN yum -y update && \
yum -y install tigervnc tigervnc-server tigervnc-server-module xrdp xinetd && \
yum clean all && rm -rf /tmp/* && \
chkconfig vncserver on 3456 && \
echo -e "\
VNCSERVERS=\"0:root 1:user\"\n\
VNCSERVERARGS[0]=\"-geometry 1280x960\"\n\
VNCSERVERARGS[1]=\"-geometry 1280x960\""\
>> /etc/sysconfig/vncservers && \
chkconfig xrdp on 3456 && \
chmod -v +x /etc/init.d/xrdp && \
chmod -v +x /etc/xrdp/startwm.sh && \
echo "gnome-session --session=gnome" > ~/.xsession
# Create User and change passwords
RUN su root sh -c "yes $ROOT_PASSWD | vncpasswd" && echo "root:$ROOT_PASSWD" | chpasswd && \
useradd user && \
su user sh -c "yes $USER_PASSWD | vncpasswd" && echo "user:$USER_PASSWD" | chpasswd
# Supervisor
RUN easy_install supervisor && \
mkdir -p /var/log/supervisor && \
mkdir -p /etc/supervisord.d && \
echo -e "\
[supervisord]\n\
nodaemon=true\n\
logfile=/var/log/supervisor/supervisord.log\n\
logfile_maxbytes=1MB\n\
logfile_backups=1\n\
loglevel=warn\n\
pidfile=/var/run/supervisord.pid\n\
[include]\n\
files = /etc/supervisord.d/*.conf"\
> /etc/supervisord.conf
# Autostart services
RUN echo -e "\
[program:xrdp]\n\
command=/etc/init.d/xrdp restart\n\
stderr_logfile=/var/log/supervisor/xrdp-error.log\n\
stdout_logfile=/var/log/supervisor/xrdp.log"\
> /etc/supervisord.d/xrdp.conf && \
echo -e "\
[program:vncserver]\n\
command=/etc/init.d/vncserver restart\n\
stderr_logfile=/var/log/supervisor/vncserver-error.log\n\
stdout_logfile=/var/log/supervisor/vncserver.log"\
> /etc/supervisord.d/vnc.conf
# Applying Gnome Settings for all users
RUN gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory \
--type bool --set /apps/nautilus/preferences/always_use_browser true && \
gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory \
--type bool --set /apps/gnome-screensaver/idle_activation_enabled false && \
gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory \
--type bool --set /apps/gnome-screensaver/lock_enabled false && \
gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory \
--type int --set /apps/metacity/general/num_workspaces 1 && \
gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory \
--type=string --set /apps/gnome_settings_daemon/keybindings/screensaver ' ' && \
gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory \
--type=string --set /apps/gnome_settings_daemon/keybindings/power ' ' && \
gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory \
--type bool --set /apps/panel/global/disable_log_out true && \
gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory \
--type int --set /apps/gnome-power-manager/timeout/sleep_computer_ac '0' && \
gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory \
--type int --set /apps/gnome-power-manager/timeout/sleep_display_ac '0' && \
gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory \
--type int --set /apps/gnome-screensaver/power_management_delay '0' && \
gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory \
--type bool --set /desktop/gnome/remote_access/enabled true && \
gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory \
--type bool --set /desktop/gnome/remote_access/prompt_enabled false
# Inform which port could be opened
EXPOSE 5900 5901 3389
# Exec configuration to container
CMD ["supervisord"]
=================================
Ubuntu Desktop based on Docker
This project provides a docker image which supports ubuntu desktop (xfce4, lightweight, fast and low on system resources), so that you can run virtual ubuntu desktop in container, you can access it by using ssh or remote desktop just like a virtual machine.
Hardware GPU accelerated rendering for 3D GUI application is supported in container, it's based on EGL by using VirtualGL, and doesn't require /tmp/.X11-unix
. if you needn't hardware GPU accelerated rendering, you can also run this container on headless host without GPU (for exmaple, Cloud Server), remote desktop and 3d GUI based on software rendering (high cpu usgae) is also supported.
Tip: Hardware GPU accelerated rendering is only verified on
ubuntu desktop system
host withmonitor
. i'm not sure if hardware GPU accelerated rendering can work for headlessubuntu server system
host.
Features
- Remote access by ssh and nomachine (remote desktop).
- OpenGL rendering based on software rasterizer (LLVMpipe) with high CPU usgae. (default)
- OpenGL rendering based on Nvidia GPU hardware-accelerated.
- Pre-installed chrome browser.
- pre-installed CUDA toolkit, which is useful for deep learning, such as pytorch, tensorflow.
Tip: it's useful to share public computer resources in labs, you can run a independent computer environment like a virtual machine, but more lightweight, and easier to deploy.
- fast to deploy multiple independent developing environment on a single computer.
- easy to share files with host or another container.
- easy to transfer environment to another new computer (save and load image).
xfce4 desktop:
Docker Image Tags:
Supported Tags (you can find here Github Tag):
- Tags of base image:
18.04
,20.04
,22.04
- Tags of image with cuda (based on
nvidia/cuda
):18.04-cu11.0.3
,20.04-cu11.0.3
etc. - naming rules is
{UBUNTU VERSION}-cu{CUDA VERSION}
, you can find supported{CUDA VERSION}
in Docker Image <nvidia/cuda>
Supported {CUDA VERSION}:
- Ubuntu18.04:
11.0.3
,11.1.1
,11.2.2
- Ubuntu20.04:
11.0.3
,11.1.0
,11.2.2
,11.3.1
,11.4.3
,11.5.2
,11.6.2
,11.7.1
- Ubuntu22.04:
11.7.1
,11.8.0
,12.0.1
,12.1.1
Preliminary
- install
nvidia driver
- install
docker
andnvidia-container-runtime
.
Tip: the newer cuda version isn't supported if you use older nvidia driver.
Quickly Start
pull docker image
docker pull gezp/ubuntu-desktop:20.04-cu11.0.3
# use aliyuncs mirror for chinese users (国内用户可使用阿里云仓库)
# docker pull registry.cn-hongkong.aliyuncs.com/gezp/ubuntu-desktop:20.04-cu11.0.3
create conatiner
# create conatiner
docker run -d --restart=on-failure \
--name my_workspace \
--cap-add=SYS_PTRACE \
--gpus all \
--shm-size=1024m \
-p 10022:22 \
-p 14000:4000 \
gezp/ubuntu-desktop:20.04-cu11.0.3
- the default username and password are both ubuntu.
access conatiner by ssh
ssh ubuntu@host-ip -p 10022
- it's recommended to use vscode + remote ssh plugin
access conatiner by nomachine client (remote desktop)
- download and install nomachine software.
- the ip is host's ip, the port is 14000.
Advanced Usage
Custom User Argument
configure USER
, PASSWORD
, GID
, UID
when you create conatiner,for example:
docker run -d --restart=on-failure \
--name my_workspace \
--cap-add=SYS_PTRACE \
--gpus all \
-e USER=cat \
-e PASSWORD=cat123 \
-e GID=1001 \
-e UID=1001 \
--shm-size=1024m \
-p 10022:22 \
-p 14000:4000 \
gezp/ubuntu-desktop:20.04-cu11.0.3
Enable GPU hardware-accelerated rendering
test VirtualGL
vglrun glxinfo | grep -i "opengl"
- hardware-accelerated is enable successfully if it's output contain
NVIDIA Product Series
.
you need add prefix vglrun
for command when you run 3D software, for example vglrun gazebo
.
Test vulkan
# vulkan info
vulkaninfo | grep -i "GPU"
# vulkan demo
vkcube
- it's output should contain
NVIDIA Product Series
if vulkan works well.
CUDA
add shell in .bashrc
to update environment variable
export CUDA_HOME=/usr/local/cuda
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
- for detailed usage, you can refer to
nvidia/cuda
Docker Image.
Build
for example
git clone https://github.com/gezp/docker-ubuntu-desktop.git
cd docker-ubuntu-desktop
# for 20.04
./docker_build.sh 20.04
# for 20.04-cu11.0 (based on nvidia/cuda)
./docker_build.sh 20.04-cu11.0
Acknowledgement
thanks to the authors of following related projects:
Tidak ada komentar:
Posting Komentar