基于该仓库ubuntu系列代码去除对宿主机X11的依赖 https://github.com/fadams/docker-gui
参考该代码仓库对显卡驱动的安装部分 https://github.com/ehfd/docker-nvidia-glx-desktop
- 镜像目的:构建基于Docker的Ubuntu系统,支持原生桌面Gnome,同时安装程序的方式和宿主机尽量做到无区别
- 该项目实现ubuntu18.04 20.04的远程连接桌面(Lightdm+Gnome+Nomachine),容器使用虚拟显示器DISPLAY=:0并支持OpenGL+Vulkan。
- 项目根据上述两个仓库制作不依赖宿主机X服务的Gnome远程桌面,项目主要用于:远程办公/运行需要Opengl/Vulkan的程序(例如:Carla / UnrealEngine 4 等)
支持的镜像Tag
- Ubuntu18.04: 18.04
- Ubuntu20.04: 20.04
- 简易教程-无需克隆仓库内容-必要脚本已拷贝至/home目录
- 必要环境:docker nVidia-docker nomachine
- 备注:
-
- 该镜像需要用到/home目录下的虚拟显示器配置脚本,将自动安装需要的驱动程序(支持Tesla/Geforce系列显卡自动安装)
-
- docker容器内部安装宿主机版本一致的显卡驱动需要docker支持'--privileged=true'参数
- 关于Gpu Cpu渲染的说明
Gpu模式下会因为深度学习服务器显卡利用率过高导致渲染速度变慢,所以请根据个人情况考虑是否使用Gpu渲染 (默认识别宿主显卡渲染 例:V100)
Cpu模式下速度会有所提升,连接速度较快可以获得较好的可视化交互效果(默认使用llvmpipe)- docker pull: 获取Ubuntu 18.04 或 20.04镜像
docker pull colorfulsky/ubuntu-gnome-nomachine:18.04
or
docker pull colorfulsky/ubuntu-gnome-nomachine:20.04 - docker run: 创建并运行容器
方式1(脚本运行-推荐):
wget https://raw.githubusercontent.com/ColorfulSS/docker-ubuntu-gnome-nomachine/master/2-remote-virtual-desktops/nx/ubuntu-18.04-gnome-nomachine/ubuntuSimple.sh
# 增加可执行权限
chmod +x ubuntuSimple.sh
# 执行自动安装配置脚本 - 需要根据提示输入相关信息
./ubuntuSimple.sh
备注:运行ubuntuSimple.sh脚本结束后,会一直停留在命令行终端界面,直接ctrl+c终止即可方式2(直接运行):
# 自行设置如下参数
# 需要使用的镜像名: NomachineBindPort
# 容器名称: CONTAINER
# Nomachine连接端口: NomachineBindPort
# SSH连接端口: SshBindPort
# Ubuntu系统自定义用户名: CreateUserAccount
# 自定义映射目录: WorkSpaceBind
docker run -d \
--restart=always \
-p $NomachineBindPort:4000 \
-p $SshBindPort:22 \
--privileged=true\
--userns host \
--device=/dev/tty0 \
--name $CONTAINER \
--ipc=host \
--shm-size 2g \
--security-opt apparmor=unconfined \
--cap-add=SYS_ADMIN --cap-add=SYS_BOOT \
-e CreateUserAccount=$CreateUserAccount \ # 设置的用户名称
-e RenderType=$RenderType \ # 使用的渲染模式 Gpu or Cpu
-v /sys/fs/cgroup:/sys/fs/cgroup \
-v $WorkSpaceBind:/data \
$IMAGE /sbin/init
# 根据显卡类型执行不同的指令
# Tesla系列: V100 A100 ...
docker exec -it $CONTAINER /home/Tesla-XorgDisplaySettingAuto.sh
# GeForce系列: 3090 2080 ...
docker exec -it $CONTAINER /home/GeForce-XorgDisplaySettingAuto.sh
- docker exec: 进入容器执行虚拟显示器配置脚本(调试使用)
# 容器名称: CONTAINER 进入root账户
docker exec -itd $CONTAINER bash SSH连接 - 考虑到安全问题-未安装SSH [如有需求请自行安装 并配置登陆安全策略]
#ssh访问容器
ssh username@host-ip -p xxxx Nomachine远程桌面连接
- 下载nomachine软件,ip为主机ip,端口为自定义端口,输入用户名+密码,进行连接即可
- 如需修改NX登陆策略为key认证: https://knowledgebase.nomachine.com/AR03Q01020

- 对于需要Vulkan支持的程序,运行安装脚本自动安装Vulkan程序(请自测支持情况)
-
- 进入/home目录
-
- 执行vulkan-ubuntu-18.04.sh 或 vulkan-ubuntu-20.04.sh脚本
-
- 执行vulkaninfo测试安装情况
Nomachine连接Ubuntu系统后需要根据客户端自定义合适的显示分辨率,进入系统后搜索Display即可
Ubuntu18.04 Dissplay分辨率设置

由于使用虚拟显示器,同时通过局域网络连接到虚拟显示器,因此需要分别对网络部分以及系统部分进行速度优化(该部分又用户自行设置合适的参数)
主要内容:关闭Gnome动画特效
命令:gsettings set org.gnome.desktop.interface enable-animations false 主要内容:通过设置硬件解码已经网络传输部分实现
Nomachine连接速度提升
参考连接:https://blog.csdn.net/weixin_39792252/article/details/80415550 中文语言支持脚本 -> 进入2-remote-virtual-desktops/nx/ubuntu-20.04-gnome-nomachine/language.sh 运行脚本
# 安装中文支持包language-pack-zh-hans:
sudo apt-get install language-pack-zh-hans
# 然后,修改/etc/environment(在文件的末尾追加):
LANG="zh_CN.UTF-8"
LANGUAGE="zh_CN:zh:en_US:en"
# 再修改/var/lib/locales/supported.d/local(没有这个文件就新建,同样在末尾追加):
en_US.UTF-8 UTF-8
zh_CN.UTF-8 UTF-8
zh_CN.GBK GBK
zh_CN GB2312
# 最后,执行命令:
sudo locale-gen
# 对于中文乱码是空格的情况,安装中文字体解决。
sudo apt-get install fonts-droid-fallback ttf-wqy-zenhei ttf-wqy-microhei fonts-arphic-ukai fonts-arphic-uming- 注:切换模式/GPU卡脚本必须在命令行中运行,请勿在虚拟桌面中运行,否则会导致脚本运行失败并卡死虚拟桌面
# 下载切换渲染模式脚本:
wget https://raw.githubusercontent.com/ColorfulSS/docker-ubuntu-gnome-nomachine/master/2-remote-virtual-desktops/nx/ubuntu-20.04-gnome-nomachine/switch_gpu_cpu.sh
# 运行脚本,按照提示输入渲染模式:( Gpu/ Cpu )
# 运行脚本,按照提示输入GPU类型:( GeForce/ Tesla )
# 运行脚本,按照提示输入GPU卡号:( 0, 1, 2, 3 ... )
# 注意:如从GPU切换至CPU同样需要输入GPU类型和GPU卡号,用于后续切换回GPU使用
# 注意:GeForce系列显卡单卡只能创建一个Xorg进程,同时需要使用DP-0作为显示端口,因此如服务器多卡请寻找未创建Xorg进程的显卡号用于虚拟显示。Tesla系列目前未发现类似限制可多次创建。
./switch_gpu_cpu.sh# 下载切换Gpu卡脚本:
wget https://raw.githubusercontent.com/ColorfulSS/docker-ubuntu-gnome-nomachine/master/2-remote-virtual-desktops/nx/ubuntu-20.04-gnome-nomachine/RenderGpuCard.sh
# 运行脚本:
./RenderGpuCard.sh $渲染模式 $GPU卡号 $GPU类型(GeForce or Tesla)
./RenderGpuCard.sh Gpu 0 GeForce
./RenderGpuCard.sh Gpu 1 GeForce
./RenderGpuCard.sh Gpu 2 GeForce
./RenderGpuCard.sh Gpu 3 Tesla-
fadams/docker-gui项目: https://github.com/fadams/docker-gui
-
该部分需要克隆本项目代码ColorfulSS/docker-ubuntu-gnome-nomachine,重新构建容器
fadams/docker-gui项目对Ubuntu:18.04添加systemd及Dbus支持,使得dockers容器内部可以启动Gnome并实现Vgl支持,以下说明为原项目编译过程!
进入0-virtual-desktops/ubuntu-18.04-gnome执行如下命令
命令:'docker build -t ubuntu-gnome:18.04 .'
镜像名称:'ubuntu-gnome:18.04'
进入1-3D-accelerated-virtual-desktops/ubuntu-18.04-gnome执行如下命令
命令:'docker build -t ubuntu-gnome-vgl:18.04 .'
镜像名称:'ubuntu-gnome-vgl:18.04'
进入2-remote-virtual-desktopsubuntu-18.04-gnome-nomachine执行如下命令
命令:'docker build -t ubuntu-gnome-nomachine:18.04 -f Dockerfile .'
镜像名称:'ubuntu-gnome-nomachine:18.04'
fadams/docker-gui项目对Ubuntu:18.04添加systemd及Dbus支持,使得dockers容器内部可以启动Gnome并实现Vgl支持,以下说明为原项目编译过程!
进入0-virtual-desktops/ubuntu-20.04-gnome执行如下命令
命令:'docker build -t ubuntu-gnome:20.04 .'
镜像名称:'ubuntu-gnome:20.04'
进入1-3D-accelerated-virtual-desktops/ubuntu-20.04-gnome执行如下命令
命令:'docker build -t ubuntu-gnome-vgl:20.04 .'
镜像名称:'ubuntu-gnome-vgl:20.04'
进入2-remote-virtual-desktopsubuntu-20.04-gnome-nomachine执行如下命令
命令:'docker build -t ubuntu-gnome-nomachine:20.04 -f Dockerfile .'
镜像名称:'ubuntu-gnome-nomachine:20.04'
运行过程和2部分内容一致,请参考上述内容! 同时项目制作中参考了三位大佬[https://github.com/fadams/] [https://github.com/ehfd] [https://github.com/gezp] 和若干教程指导,希望能够作为更好的远程办公和科研学习平台,制作镜像目的是实现和宿主机类似的dockers容器!感谢三位大佬的教程和指导!
# 以cuda 11.0为例
# 访问cuda网站选择对应版本cuda
Operating System: Linux
Architecture: x86_64
Distribution: Ubuntu
Version: 18.04
Installer Type: runfile(local)
网站链接:https://developer.nvidia.com/cuda-11.0-download-archive?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1804&target_type=runfilelocal
注:如需cuda 1x.x请更换https://developer.nvidia.com/cuda-11.0-download-archive?为https://developer.nvidia.com/cuda-1x.x-download-archive?
# 下载runfile文件
wget http://developer.download.nvidia.com/compute/cuda/11.0.2/local_installers/cuda_11.0.2_450.51.05_linux.run
# 运行runfile文件
sudo sh cuda_11.0.2_450.51.05_linux.run
注:请取消cuda安装过程中出现的Nvidia Driver安装选项,该选项会与容器内部驱动冲突
# 配置环境变量
Please make sure that
- PATH includes /usr/local/cuda-11.0/bin
- LD_LIBRARY_PATH includes /usr/local/cuda-11.0/lib64, or, add /usr/local/cuda-11.0/lib64 to /etc/ld.so.conf and run ldconfig as root
# 测试cuda安装
nvcc -V# 访问鱼香ros获取安装脚本
wget http://fishros.com/install -O fishros && . fishros




