Docker run desktop environment Docker run desktop environment docker docker

Docker run desktop environment


That is I was looking for, the simplest form of the desktop in Docker:

FROM ubuntuRUN apt-get updateRUN apt-get install xfce4 -yRUN apt-get install xfce4-goodies -yRUN apt-get purge -y pm-utils xscreensaver*RUN apt-get install wget -yEXPOSE 5901RUN wget -qO- https://dl.bintray.com/tigervnc/stable/tigervnc-1.8.0.x86_64.tar.gz | tar xz --strip 1 -C /RUN mkdir ~/.vncRUN echo "123456" | vncpasswd -f >> ~/.vnc/passwdRUN chmod 600 ~/.vnc/passwdCMD ["/usr/bin/vncserver", "-fg"]

Unfortunately I could not sort out with x11vnc and xvfb. But TigerVNC turned out much better.

This sample generate container with xfce gui and run vncserver with 123456 password. There is no need to overwrite ~/.vnc/xstartup manually because TigerVNC starts up X server by default!

To run the server:

sudo docker run --rm -dti -p 5901:5901 3ab3e0e7cb

To connect there with vncviewer:

vncviewer -AutoSelect 0 -QualityLevel 9 -CompressLevel 0 192.168.1.100:5901

Also you could not care about screen resolution because by default it will resize to fit your screen:F8 vncviewer menu

You may also encounter the issue with ipc_channel_posix (chrome and other browsers will not work properly) to eliminate this run container with memory sharing:

docker run -d --shm-size=2g --privileged -p 5901:5901 image-name


x11docker allows to run desktop environments as well as single GUI applications in docker.

Could you give some Dockerfile lines in order reach the goal?

Example desktop images on docker hub.

x11docker does a lot of setup to keep container isolation and provides some additional options like hardware acceleration or pulseaudio sound. Example:

x11docker --desktop x11docker/lxde

x11docker also supports network setups with SSH, VNC and HTML5

Example for SSH setup with xpra:

read Xenv < <(x11docker --xdummy --display=30 x11docker/lxde pcmanfm)echo $Xenv && export $Xenv# replace "start" with "start-desktop" to forward a desktop environmentxpra start :30 --use-display --start-via-proxy=no

From client system, connect with

xpra attach ssh:HOSTNAME:30  # replace HOSTNAME with IP or host name of ssh server

Without x11docker:

A quite short setup using Xephyr as nested X server on host is:

Xephyr :1docker run -v /tmp/.X11-unix/X1:/tmp/.X11-unix/X1:rw \           -e DISPLAY=:1 \           x11docker/xfce

A short Dockerfile with Xfce desktop:

FROM debian:stretchENV DEBIAN_FRONTEND noninteractiveRUN apt-get update && apt-get install -y --no-install-recommends xfce4 dbus-x11CMD startxfce4