docker-ubuntu-vnc-desktop
![68747470733a2f2f696d672e736869656c64732e696f2f646f636b65722f70756c6c732f646f726f77752f7562756e74752d6465736b746f702d6c7864652d766e632e737667](https://camo.githubusercontent.com/d3af1e6a9eb04377a28bcbed1ead9393a948742a/68747470733a2f2f696d672e736869656c64732e696f2f646f636b65722f70756c6c732f646f726f77752f7562756e74752d6465736b746f702d6c7864652d766e632e737667)
![68747470733a2f2f696d672e736869656c64732e696f2f646f636b65722f73746172732f646f726f77752f7562756e74752d6465736b746f702d6c7864652d766e632e737667](https://camo.githubusercontent.com/f5358ba005bb142aaf7d2d88b237db93363c2904/68747470733a2f2f696d672e736869656c64732e696f2f646f636b65722f73746172732f646f726f77752f7562756e74752d6465736b746f702d6c7864652d766e632e737667)
Docker image to provide HTML5 VNC interface to access a Ubuntu 18.04 LXDE desktop environment.
Quick Start
Run the docker container and access with port 6080
docker run -p 6080:80 -v /dev/shm:/dev/shm dorowu/ubuntu-desktop-lxde-vnc
![c00551340cdd9ee1330a9f64c629229d.png](https://img-blog.csdnimg.cn/img_convert/c00551340cdd9ee1330a9f64c629229d.png)
Ubuntu Version
Choose your favorite Ubuntu version with tags
focal: Ubuntu 20.04 (latest)
focal-lxqt: Ubuntu 20.04 LXQt
bionic: Ubuntu 18.04
bionic-lxqt: Ubuntu 18.04 LXQt
xenial: Ubuntu 16.04 (deprecated)
trusty: Ubuntu 14.04 (deprecated)
VNC Viewer
Forward VNC service port 5900 to host by
docker run -p 6080:80 -p 5900:5900 -v /dev/shm:/dev/shm dorowu/ubuntu-desktop-lxde-vnc
Now, open the vnc viewer and connect to port 5900. If you would like to protect vnc service by password, set environment variable VNC_PASSWORD, for example
docker run -p 6080:80 -p 5900:5900 -e VNC_PASSWORD=mypassword -v /dev/shm:/dev/shm dorowu/ubuntu-desktop-lxde-vnc
A prompt will ask password either in the browser or vnc viewer.
HTTP Base Authentication
This image provides base access authentication of HTTP via HTTP_PASSWORD
docker run -p 6080:80 -e HTTP_PASSWORD=mypassword -v /dev/shm:/dev/shm dorowu/ubuntu-desktop-lxde-vnc
SSL
To connect with SSL, generate self signed SSL certificate first if you don't have it
mkdir -p ssl
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout ssl/nginx.key -out ssl/nginx.crt
Specify SSL port by SSL_PORT, certificate path to /etc/nginx/ssl, and forward it to 6081
docker run -p 6081:443 -e SSL_PORT=443 -v ${PWD}/ssl:/etc/nginx/ssl -v /dev/shm:/dev/shm dorowu/ubuntu-desktop-lxde-vnc
Screen Resolution
The Resolution of virtual desktop adapts browser window size when first connecting the server. You may choose a fixed resolution by passing RESOLUTION environment variable, for example
docker run -p 6080:80 -e RESOLUTION=1920x1080 -v /dev/shm:/dev/shm dorowu/ubuntu-desktop-lxde-vnc
Default Desktop User
The default user is root. You may change the user and password respectively by USER and PASSWORD environment variable, for example,
docker run -p 6080:80 -e USER=doro -e PASSWORD=password -v /dev/shm:/dev/shm dorowu/ubuntu-desktop-lxde-vnc
Deploy to a subdirectory (relative url root)
You may deploy this application to a subdirectory, for example /some-prefix/. You then can access application by http://127.0.0.1:6080/some-prefix/. This can be specified using the RELATIVE_URL_ROOT configuration option like this
docker run -p 6080:80 -e RELATIVE_URL_ROOT=some-prefix dorowu/ubuntu-desktop-lxde-vnc
NOTE: this variable should not have any leading and trailing splash (/)
Sound (Preview version and Linux only)
It only works in Linux.
First of all, insert kernel module snd-aloop and specify 2 as the index of sound loop device
sudo modprobe snd-aloop index=2
Start the container
docker run -it --rm -p 6080:80 --device /dev/snd -e ALSADEV=hw:2,0 dorowu/ubuntu-desktop-lxde-vnc
where --device /dev/snd -e ALSADEV=hw:2,0 means to grant sound device to container and set basic ASLA config to use card 2.
Launch a browser with URL http://127.0.0.1:6080/#/?video, where video means to start with video mode. Now you can start Chromium in start menu (Internet -> Chromium Web Browser Sound) and try to play some video.
Following is the screen capture of these operations. Turn on your sound at the end of video!
![e68c4d30e87b146a12c1650f84f824c1.png](https://img-blog.csdnimg.cn/img_convert/e68c4d30e87b146a12c1650f84f824c1.png)
Generate Dockerfile from jinja template
Dockerfile and configuration can be generated by template.
arch: one of amd64 or armhf
flavor: refer to file in flavor/flavor.yml
image: base image
desktop: desktop environment which is set in flavor
addon_package: Debian package to be installed which is set in flavor
Dockerfile and configuration are re-generate if they do not exist. Or you may force to re-generate by removing them with the command make clean.
Troubleshooting and FAQ
License
See the LICENSE file for details.