Full Desktop in Docker 
Tags: docker, showdev, devops, beginners
Published: 2020-06-21 22:02:49

>If you don't know what is docker? First, read this article: [Dockers for Extreme Beginners in Desi (layman ) language.](https://dev.to/manishfoodtechs/docker-for-extreme-beginners-in-desi-layman-language-1e0n). 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](https://b00merang.weebly.com/licensing.html) and wallpapers from [pixabay](https://pixabay.com).

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

## Screenshots:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/q631k9gjvjbvy2wfu3gd.jpeg)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/u8978h5v35iz3amtdvf0.jpeg)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/tnwt26n5jqh3zx16s27a.jpeg)

And how the desktop looks in small screen mobile:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/n1icdvzwuee12vj2nejj.jpeg)

##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](https://dev-to-uploads.s3.amazonaws.com/i/7d0ec66w9u7epikd5tqu.png)

**(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](https://www.google.com/search?q=image+how+to+start+rdp+in+windows&client=firefox-b-d&sxsrf=ALeKk00mz32btEmb_l6-ANGwMMeDVOG7Xw:1592774401025&source=lnms&tbm=isch&sa=X&ved=2ahUKEwifnoWD65PqAhUCyzgGHfQXB5IQ_AUoAnoECAwQBA&biw=1366&bih=654)

**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.
- Podman = docker - daemon - root 
read: {% link https://dev.to/manishfoodtechs/rootless-docker-kick-docker-hackers-and-make-docker-more-secure-new-concept-70g %}

-  Desktop(Vnc based) : {% link https://dev.to/manishfoodtechs/your-complete-online-desktop-hosted-on-server-in-just-5-00-4la5 %}

I hope you people like the above article and learned something.
######***IMP REQUEST:***
###### You are most welcome to join my team [ form for joining ](https://forms.gle/pSCALuEWHus3pg9F6).
###### *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.

![](https://media2.giphy.com/media/oNrPzIy3OhHm7zrvA3/source.gif)

###### 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