2018-09-18 - Run VisualStudioCode in a container (in progress)

Repository: https://bitbucket.org/geircode/run_visualstudiocode_in_a_container

Goal:

  • Run Visual Studio Code in a Container
  • Connect to it with Windows GUI
  • Debug a Python script
  • Debug a Python script running in another Container in the same network as the VisualStudioCode Container.

Why?

  • Develop and debug code directly from within a Container and its environment
  • Isolation
  • Run anywhere


Has it been done before?

Yes, it appears so, and plenty of times:

https://github.com/cmiles74/docker-vscode

https://github.com/exadra37-docker-images/visual-studio-code

https://grigio.org/visual_studio_code_docker/

https://github.com/Joengenduvel/docker-vscode


Seems that I need to do this from a Linux VM in order to get the GUI, but it's also possible to install a X11 simulator on Windows


Hmm, can I use a X11 display server to connect a x-terminal to a Linux container?

http://christopher5106.github.io/admin/2018/02/02/configure-windows-10-for-ubuntu.html

https://www.howtogeek.com/261575/how-to-run-graphical-linux-desktop-applications-from-windows-10s-bash-shell/

Yep. That is definitely possible, and it is pretty cool.


And this article actually shows how to install and connect a X-terminal on Windows 10 to a Ubuntu Docker Container running locally:

https://dev.to/darksmile92/run-gui-app-in-linux-docker-container-on-windows-host-4kde

Next, it would also be fun to connect this X-terminal to a remote container running somewhere in the cloud?(smile)

First attempt

First I install the Windows X Server as described here: https://dev.to/darksmile92/run-gui-app-in-linux-docker-container-on-windows-host-4kde

And then using the Dockerfile from https://github.com/Joengenduvel/docker-vscode/blob/master/Dockerfile

Or just run the script I created here: https://bitbucket.org/geircode/run_visualstudiocode_in_a_container/src/540ed93c0fc6c5760dfa277b676a1898cb992403/ubuntu/Dockerfile.build.bat


And it works!

But this throws alot of errors constantly:


I get so many errors using this setup with Windows X Server that it is not really very practiable to use at this point. I had probably gotten it to work better at some point, but at the moment it might be better to use Ubuntu's own X server natively.

Installing Ubuntu with Docker in Hyper-V (Azure VM)

This guide describes how to install Ubuntu on my Windows 10:

https://www.windowscentral.com/how-run-linux-distros-windows-10-using-hyper-v

I thought about doing this with a Ubuntu VM in Azure, but apparently Remote Desktop Protocol (RDP) is not very well supported on Linux and has to 'fixed' on order to work properly and fast.

But why not, lets try:

https://buildazure.com/2018/02/28/how-to-setup-an-ubuntu-linux-vm-in-azure-with-remote-desktop-rdp-access/

sudo -s 
apt-get update
apt-get install lxde -y
apt-get install xrdp -y
/etc/init.d/xrdp start

I use my workspace container to login and run these commands through SSH.

Now the guide says that I am ready to login remotely.

How to connect to VM

  • Click the "Connect"

  • Click "Download RDP File"

Yay!(smile)

How to login?

When I created the Ubuntu VM, I created the user "garg" with a SSH public key and not a password.

Guess I have to give the user "root" a password:

and try to login again:

Using "Xorg" and the user "root" and the new password:

Whoho! Nice.

After trying this GUI a little I find it to be very cumbersome and lacking in functionality such as how to change the language of the input. I need to change to a norwegian keyboard, but can't do this from GUI.

The alternatives:

The Linux way of distributing the effort into different solutions instead of just having one way of doing stuff. That's why they created "Canonical":

Canonical was founded with the goal of bringing polish, consistency and usability to the Linux desktop.


https://sorcia25.wordpress.com/2018/03/02/how-to-setup-an-ubuntu-linux-vm-in-azure-with-remote-desktop-rdp-access-ubuntu-desktop-gui/

The good thing now is that I already have a lightweight GUI and that makes it easier to install another GUI. Alriiighty then.

Image result for time warp

Ok, fast forward. It turned out that my setup didnt work so good. Mainly because I installed more than one GUI on the Ubuntu server, and I didnt get the xRDP to switch to the "Ubuntu Desktop" GUI.

I have learned so much:

  • LXDE was too lightweight for me
  • When I install more than one GUI on the Ubuntu server, the xRDP does not find the installed "Ubuntu Desktop" that is also running, but I can see it from the Azure boot diagnostics.
  • It's possible to change the keyboard input language => http://c-nergy.be/blog/?p=9962

Next:

  • Start with a new fresh Ubuntu Azure VM with the same setup
  • Install "Ubuntu Desktop"
  • Use "xRDP – Perform a custom installation on Ubuntu 18.04.x"
  • Change the keyboard input language => http://c-nergy.be/blog/?p=9962
  • Install Visual Studio Code
  • Install Docker
  • Install Visual Studio Code inside the Container
  • Show Visual Studio Code running inside the Container natively in "Ubuntu Desktop"
  • Debug Python script directly from inside the Container from "Docker Host"


Start with a new fresh Ubuntu Azure VM with the same setup