默认用户名和密码都是 ubuntu,暴露端口前务必改掉;3D 程序要加 vglrun 前缀才会走 GPU 加速,否则默认软件渲染;CUDA 环境变量需自行写入 .bashrc,且旧 nvidia 驱动不支持较新 CUDA 版本。
docker-ubuntu-desktop
gezpMIT更新放缓把 Ubuntu 桌面塞进 Docker 镜像,支持 NVIDIA GPU 硬件加速的图形应用,可通过 SSH 或远程桌面像云主机一样访问。
Docker Image for Ubuntu Desktop which support HW GPU accelerated GUI apps. you can access the Container with ssh or remote desktop, just like Cloud VM.
docker pull gezp/ubuntu-desktop:20.04-cu11.0.3
docker run -d --restart=on-failure --name my_workspace --cap-add=SYS_PTRACE --gpus all --shm-size=1024m -e USER=ubuntu -e PASSWORD=ubuntu -e GID=$(id -g) -e UID=$(id -u) -p 10022:22 -p 14000:4000 -p 15000:5000 gezp/ubuntu-desktop:20.04-cu11.0.3需要安装 nvidia 驱动和 nvidia-container-runtime,运行时用 --gpus all 挂载 GPU;无 GPU 的无头主机也能跑,但只能软件渲染且 CPU 占用高。README 称硬件加速仅在带显示器的 Ubuntu 桌面主机上验证过,无头 Ubuntu server 主机未确认。
在 Docker 里跑带 GPU 加速的 Ubuntu 桌面,用 SSH 或远程桌面像云主机一样访问
把 Ubuntu 桌面塞进 Docker 镜像,支持 NVIDIA GPU 硬件加速的图形应用,可通过 SSH 或远程桌面像云主机一样访问。
核心能力
- 基于 xfce4 的轻量桌面,资源占用低
- 用 VirtualGL 通过 EGL 实现 GPU 硬件加速渲染,无需 /tmp/.X11-unix
- 支持 nomachine、kasmvnc、novnc 三种远程桌面方式
- 默认用 LLVMpipe 软件渲染,无 GPU 主机也能跑
- 预装 CUDA toolkit 与 Firefox,镜像按 Ubuntu 版本和 CUDA 版本打标签
容易踩的坑
暂无 release 数据(可能没有发版,或尚未同步)。
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
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 systemhost withmonitor. i'm not sure if hardware GPU accelerated rendering can work for headlessubuntu server systemhost.
Features
- Remote access by ssh and remote desktop (nomachine/kasmvnc/novnc).
- OpenGL rendering based on software rasterizer (LLVMpipe) with high CPU usgae. (default)
- OpenGL rendering based on Nvidia GPU hardware-accelerated.
- Pre-installed Firefox web 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,24.04 - Tags of image with cuda (based on
nvidia/cuda):18.04-cu11.0.3,20.04-cu11.0.3etc. - 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,12.2.2,12.3.2,12.4.1,12.5.1- Ubuntu24.04:
12.5.1,12.6.2
Preliminary
- install
nvidia driver - install
dockerandnvidia-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 container
# create container with nomachine
docker run -d --restart=on-failure \
--name my_workspace \
--cap-add=SYS_PTRACE \
--gpus all \
--shm-size=1024m \
-e USER=ubuntu \
-e PASSWORD=ubuntu \
-e GID=$(id -g) \
-e UID=$(id -u) \
-p 10022:22 \
-p 14000:4000 \
-p 15000:5000 \
gezp/ubuntu-desktop:20.04-cu11.0.3
# create container with kasmvnc/novnc
docker run -d --restart=on-failure \
--name my_workspace \
--gpus all \
--shm-size=1024m \
-e USER=ubuntu \
-e PASSWORD=ubuntu \
-e GID=$(id -g) \
-e UID=$(id -u) \
-e REMOTE_DESKTOP=kasmvnc \
-p 10022:22 \
-p 14000:4000 \
-p 15000:5000 \
gezp/ubuntu-desktop:20.04-cu11.0.3
- the default username and password are both ubuntu.
access container by ssh
ssh ubuntu@host-ip -p 10022
- it's recommended to use vscode + remote ssh plugin
access container by remote desktop (nomachine)
- download and install nomachine software.
- the ip is host's ip, the port is 14000.
access container by remote desktop (kasmvnc/novnc)
- use browser to access
https://<host-ip>:14000(chrome is recommended)
Tip
novncoption based on TurboVNC + noVNC, which are free and open-source softwares.
features of moachine/kasmvnc/novnc:
- moachine: need client software to access remote desktop, and support audio, uploads, downloads.
- kasmvnc/novnc: provide remote web-based access to desktop, but it doesn't support audio, uploads, downloads, and microphone pass-through.
access container by code-server (VS Code in the browser)
- use browser to access
https://<host-ip>:15000(chrome is recommended)
Advanced Usage
Custom User Argument
configure by setting environment variables when you create container.
REMOTE_DESKTOP: nomachine (default) , kasmvnc, novnc.VNC_THREADS: RectThread num for vncserver, only used whenREMOTE_DESKTOP= kasmvnc. default is 2, set 0 for auto.HTTPS_CERT: SSL pem certificate file path to use for https server(kasmvnc/nonvc).HTTPS_CERT_KEY: SSL pem key file path to use for https server(kasmvnc/nonvc).DISABLE_HTTPS: set 1 for http server mode, which is useful for reverse proxy.
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 Seriesif 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/cudaDocker 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.3 (based on nvidia/cuda)
./docker_build.sh 20.04-cu11.0.3
Acknowledgement
thanks to the authors of following related projects: