Saturday, August 29, 2020

X Server on Windows Host for Linux Virtual Machine Guests

We can run thin Linux (or other UNIX) virtual machine guests systems including Docker containers without GUI. Linux systems often need memory on the order of hundred megabytes to run. Without GUI, we can run more virtual machine instances and run the instances faster. These instances on the VMs or in the containers can still run GUI applications if we install X server on the host. 

For host systems that comes with X natively, this is quite easy, and just need to inform the guest which display to use. However, not all host systems have X natively. For instance, Windows does not come with one natively. Luckily, there are  a few free or inexpensive X Server for Windows available. Below are the simple steps to realize this idea on a Windows host,

  1. Download and install vcXsrv
  2. Launch vcXsrv using the XLaunch shutcut. If you run it on the host for the guest Linux systems on the hosted VMs, and the host has firewall like Windows Defender to prevent outside access to the X server, you can safely check "Disable access control" to allow any X client to display on the server. 
  3. vcXsrv has a tray icon on Windows. Right-click the tray icon, open "Show log", and the log will tell us what host IP addresses the X server is bound to, such as, 192.168.1.101. 
  4. Log in to a Linux guest,  such as, ssh to the Linux guest,
  5. Set the DISPLAY environment variable, e.g., if our host IP address is 192.168.1.101
    export DISPLAY=192.168.1.101:0.0
    
  6. Lanuch a GUI application from the Linux guest, and we shall see it's running and the X server is displaying the GUI.

Very importantly, we are not using SSH's X forwarding feature here. Not everyone can successfully enable SSH's X forwarding feature smoothly. This method is simpler to set up to those who have a problem to set SSH's X forwarding up. 

In next post, we shall discuss what it takes to set up SSH's X forwarding.


No comments:

Post a Comment