DEV Community

Cover image for Full Desktop in Docker
manish srivastava
manish srivastava

Posted on

Full Desktop in Docker

If you don't know what is docker? First, read this article: Dockers for Extreme Beginners in Desi (layman ) language.. This article got 9k+ readings in the last 20 days and count increasing.

What we are building today?

We are building a fully functional desktop inside a docker container. The Ubuntu latest release Focal Fossa or Ubuntu:20.04 is used to build this container. Desktop Environment is Xfce with windows theme from b00merang Project and wallpapers from pixabay.

VNC & RDP are two technologies to connect to remote desktops. I used RDP and VNC is left for you to try :)

Screenshots:

Alt Text
Alt Text
Alt Text

And how the desktop looks in small screen mobile:
Alt Text

Why we are building?

(1)You can find a number of docker images with a "desktop environment"on google.But these images are custom build i.e leaving libre office suite etc to remain light in size.
(2) Being a docker image you can spin a desktop in a click.

Why Xfce Desktop Environment?

Xfce is lighter than mate and gnome. Being lighter, performance is better in the container.

How to create a desktop in a docker container?

(1) Pull Image and Run:manishfoodtechs/xfcefulldesktop_ubuntu20.4

docker run -it -p 9096:3389 -e 3389 --shm-size 2g manishfoodtechs/xfcefulldesktop_ubuntu20.4

In above command:

  • we are opening port of host 9096 to listen port of container 3389. You can use any port in place of 9096 but Port 3389 is a standard port of xrdp.
  • we are exposing container's 3389 port with -e 3389
  • shm-size 2g is given so that Firefox doesn't break.

Look at this terminal image :

Alt Text

(2) Service start xrdp:

/etc/init.d/xrdp restart

In above command:
-We are starting xrdp

then, ### visit : hostip:9096 in RDP client of your PC. More about RDP here

USER ID: root and Password: 123456 . Please don't forget to change password with command passwd root and add some more users.

(3) Troubleshoot:

  • wait on black / blue screen in 20-30 seconds desktop will get up.
  • If, rdp is not connecting, then get inside the container shell and run /etc/init.d/xrdp restart as you did in step (2).

IMPORTANT:
Docker is not meant for running complete desktops but running apps. The closet container like VM machine is LXD. If you had visited my above-said article (docker in desi language) you would be able to spin a desktop in lxd container.

More?

Try to pull the container with podman over gvisor.


I hope you people like the above article and learned something.

IMP REQUEST:
You are most welcome to join my team form for joining .
Also you are most welcome to join OPEN SOURCE INTELLIGENT SYSTEM (OSINT) if you can help in open source project regarding safeguarding humans from various diseases like CORONA outbreak
https://github.com/Manishfoodtechs/OSINTHRH/wiki

Contact email: Manishfoodtechs@gmail.com.

If you have any problem, our team is also engaged in professional consultancy and delivery.

image credit: manish srivastava
Further Read : x11docker and dx-11 https://dev.to/brickpop/my-dream-come-true-launching-gui-docker-sessions-with-dx11-in-seconds-1a53

Top comments (6)

Collapse
 
huncyrus profile image
huncyrus

Interesting, personally I never checked out whether is possible or not.

My question is: What's the point to use docker for GUI OS ? Why not just use virtualbox what could give us 100% (or close to that) desktop experience and functionality?

Collapse
 
manishfoodtechs profile image
manish srivastava • Edited

1. What's the point to use docker for GUI OS ?

Docker is not meant for running complete desktops but running apps. The closet container like VM machine is LXD. If you had visited my above-said article (docker in desi language) you would be able to spin a desktop in lxd container. Read this to know difference between Metal Server, VPS, Containers, Hypervisor -1 & Hypervisor -2 types

2.Why not just use virtualbox what could give us 100% (or close to that) desktop experience and functionality?

Suppose , We have to spin 25 Desktops from 16 MB RAM, 21TB HDD Host with each client desktop with guaranteed 2GB RAM.
(1) Virtual Box doesn't do Resource Pooling (of most costly resources like RAM, cores) among clients VMs. This means you can have only 7 client PC running simultaneously ( 2 X 7 GB = 14 GB and leaving 2 GB for the host).
(2) Networking is an issue with Virtual Box. This is why we don't use Virtual Box for Hosting on the server. The Below article may help you :

Further Reading...

The Story of cloud Brothers.

Must Read: Part 1 and Part-2 and Part-3

Collapse
 
huncyrus profile image
huncyrus

Thank you, but I am quite aware of the technical debt/requirement for such a project (I worked with companies what used slim/light clients where a central machine held the data and computation power and everything was synced).

More like I was curious of the use case.

Thread Thread
 
manishfoodtechs profile image
manish srivastava

Use cases
The list grows pretty much as you imagination allows. But a few examples include:

  • Realistic distro hopping. Try a new distribution or desktop environment before you make it your daily driver.
  • Evaluate the real performance instead of hoping that a native installation would be smoother.
  • Full portability. Copy your session’s data to a brand new computer, rebuild the Docker image and continue to work as if nothing ever happened.
    • Give your developers a reference workstation Dockerfile that they can still customize. Avoid the “works on my machine” problem.
    • Speed up the landing of new developers with an already functional toolkit.
    • Post your session’s Dockerfile on your StackOverflow question or GitHub issue. Let others reproduce the exact same environment you have when you encounter that nasty error.
  • Deprecation proof development environments. Your legacy React Native or Cordova setup is carved in stone. If an SDK upgrade breaks a project, nothing else will be affected. Rerun your stable image and npm install will keep working as usual.
  • Post your session’s Dockerfile on a public repo. Let others clone it, fork it and make it even cooler.
  • Evaluate bloated/unsafe software on a clone of your workstation and drop the changes when you are done experimenting.
  • Upgrade and downgrade at will, without the risk of losing any local data.
  • Docker build will never interact with any session, even if it’s running. -Replace your all-in-one bloated computer with minimal isolated systems that you can use on demand. One for your sysadmin work, one for your side projects, one for gaming, one for anonymous browsing, etc.
  • Forget about multiple SSH key management by having a different session for each project, with its corresponding key files and credentials.
  • Cybercafes, where a Linux computer spins up a fresh disposable desktop when you pay for it and terminates it when you are done.
  • Record a screencast of that upcoming Gnome/KDE release and transfer the video file to your main system right away. No VirtualBox Guest Additions needed.
  • If you write extensions for KDE, Gnome, etc., you can publish a Dockerfile to let people run sessions with them preinstalled.

You name it. The more you use it, the more you realize the enormous potential it has.

Above is abstract from :

Further Read : x11docker and dx-11 dev.to/brickpop/my-dream-come-true...

This link already mentioned in Article.

Collapse
 
lestephane profile image
Le Stephane

Hello, I'm interested in this, but I won't run it without looking at the Dockerfile. Do you have a github repo for this? I looked at your Github account, and there is no exact repository name match for xfcefulldesktop_ubuntu20.4... Cheers

Collapse
 
manishfoodtechs profile image
manish srivastava

Hey stephane , thanks for feedback.
This docker image is created from a custom made Ubuntu focal fosa by me. You can pull it by manishfoodtechs/ubus204 and then follow to download xfce . Gnome and mate are heavier than xfce.