Repository: https://bitbucket.org/geircode/run_visualstudiocode_in_a_container
Goal:
Why?
I was inspired by this article https://nickjanetakis.com/blog/using-wsl-and-mobaxterm-to-create-a-linux-dev-environment-on-windows that explains how to setup a similar environment using WSL.
Prerequisites:
To be able to see Visual Studio Code on Windows, it needs a X-terminal server that the container can connect to and show/render the GUI.

Here you see the X server running in the icon up in the right corner.
Now Windows is ready to accept incoming X-terminal connections from any linux environment.
git clone https://bitbucket.org/geircode/run_visualstudiocode_in_a_container
cd /d %~dp0
docker rm -f visualstudiocode-1
docker-compose -f docker-compose.yml down --remove-orphans
docker-compose -f docker-compose.yml up -d --build --remove-orphans
pause
docker exec -it visualstudiocode-1 /bin/bash
This script will build the Docker Container Image if it does not exist and start up the container.

When the container is starting up, you will get a lot of confirmation boxes from MobaXterm. Click on 'yes' on all of them, and behold:

This is a fully functional Visual Studio Code instance running inside the container!
Login to the container using bash
docker exec -it visualstudiocode-1 /bin/bash
and run "top" to see running processes.

Code is running and connected to the X-terminal in Windows.
First, open a folder in Visual Studio Code:


You will encounter this popup:

Click on "Allow" so that the Python plugin will be able to find the Python modules in this repository.
Go to MobXterm and open Settings, then X11:

Lots of small stuff has been configured to make this work properly. Explore the Dockerfile and various settings/config files in the repository. In particular the DISPLAY environment variable.
This is only the beginning. Any other Linux app with a GUI can be opened this way. It's also possible to automate most of the manual steps in this how-to.
This is some powerful stuff. It's possible to create shared development container images with preinstalled stuff on it. You can even run it and attach remotely from another Visual Studio Code using the Live Share. You can commit and upload the image, download it to your other development computers and start coding immediately. Create volumes and/or mount local directory into the container. There are a lot of options:)
Content type
Image
Digest
Size
313.5 MB
Last updated
almost 7 years ago
docker pull geircode/visualstudiocode