Windows Subsystem for Linux allows to run Linux binaries directly under Windows. Next logical step might be to try to install Docker on the Linux, and then run images.
It might work, never tried. But, I’ve discovered (quite late – I have to admit) a way to ‘mount’ directly any Docker image as a subsystem for Windows 10.
What is needed:
- Windows 10 – With Anniversary update / Insider
- Repository: RoliSoft/WSL-Distribution-Switcher
- Example image: trzeci/emscripten:sdk-master-64bit
Install an image as Windows Subsystem for Linux
python get-prebuilt.py trzeci:emscripten_sdk-master-64bit python install.py trzeci:emscripten_sdk-master-64bit
In case of my image, and most likely more images, we have problems like:
- No access to root privileges
- Missing sudo
In order to fix it:
# cmd / powershell lxrun /setdefaultuser root bash #now we are under linux root@DZIK:/mnt/d/WSL-Distribution-Switcher# su -l root@DZIK:~# passwd root@DZIK:~# apt install sudo root@DZIK:~# sudo adduser trzeci sudo root@DZIK:~# exit root@DZIK:~# exit # CMD lxrun /setdefaultuser trzeci bash
Test run of Emscripten project
Let’s create a file test.cpp
#include <iostream> int main() { std::cout << "HELLO FROM DOCKER!"; return 0; }
trzeci@DZIK:/mnt/d/emscripten-docker$ emcc test.cpp -o test.js WARNING:root:Could not verify LLVM version: [Errno 2] No such file or directory WARNING:root:could not check fastcomp: [Errno 2] No such file or directory INFO:root:(Emscripten: Running sanity checks) CRITICAL:root:Cannot find /usr/bin/clang++, check the paths in ~/.emscripten
Why is that:
- emsdk_env.sh is not configured correctly, that is I have incorrect environment variables:
trzeci@DZIK:/mnt/d/emscripten-docker$ export EMSCRIPTEN=/emsdk_portable/ trzeci@DZIK:/mnt/d/emscripten-docker$ export LLVM=/emsdk_portable/clang/fastcomp/build_master_64/bin/
Result:
trzeci@DZIK:/mnt/d/emscripten-docker$ emcc test.cpp -o test.js INFO:root:(Emscripten: Running sanity checks) WARNING:root:java does not seem to exist, required for closure compiler, which is optional (define JAVA in /home/trzeci/.emscripten if you want it) WARNING:root:closure compiler will not be available WARNING:root:generating system library: libcxx.a... WARNING:root: ok WARNING:root:generating system library: libcxxabi.bc... WARNING:root: ok WARNING:root:generating system library: libc.bc... WARNING:root: ok WARNING:root:generating system library: dlmalloc.bc... WARNING:root: ok trzeci@DZIK:/mnt/d/emscripten-docker$ nodejs test.js HELLO FROM DOCKER!
Some comments:
- It did rebuild all bc, even if the image contains pre-build cache: It’s because cache has been generated on
root
account. - The image doesn’t work out of the shelf: Something to improve :)
More examples and links:
- Install fedora: https://www.variantweb.net/blog/running-fedora-on-windows-10-using-wsl/
- sub-reddit: https://www.reddit.com/r/bashonubuntuonwindows