Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker run desktop environment

Tags:

docker

vnc

xvfb

The question is most clear,
How to start complete desktop environment (KDE, XFCE, Gnome doesn't matter) in the Docker remote container.

I were digging over the internet and there are lots of questions about the related topic, but not the same, they all about how to run GUI application not the full desktop.

What I found out:

  • Necessary run Xvfb
  • Somehow run e.g. Xfce in that FrameBuffer
  • Allow x11vnc to share that running X environment

But I'm stuck here actually, always getting whatever errors:

... (EE) Invalid screen configuration 1024x768 for -screen 0
... Cannot open /dev/tty0 (No such file or directory)

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

like image 797
Ivan Talalaev Avatar asked Feb 04 '23 03:02

Ivan Talalaev


1 Answers

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

FROM ubuntu
RUN apt-get update
RUN apt-get install xfce4 -y
RUN apt-get install xfce4-goodies -y
RUN apt-get purge -y pm-utils xscreensaver*
RUN apt-get install wget -y

EXPOSE 5901

RUN wget -qO- https://dl.bintray.com/tigervnc/stable/tigervnc-1.8.0.x86_64.tar.gz | tar xz --strip 1 -C /
RUN mkdir ~/.vnc
RUN echo "123456" | vncpasswd -f >> ~/.vnc/passwd
RUN chmod 600 ~/.vnc/passwd


CMD ["/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
like image 71
Ivan Talalaev Avatar answered Mar 31 '23 23:03

Ivan Talalaev