Technically Impossible

Lets look at the weak link in your statement. Anything "Technically Impossible" basically means we haven't figured out how yet.

Run any Linux distribution on WSL - Case: Clear Linux OS and its Gnome desktop

Abstract

tar file exported from Docker container can be imported to WSL2. In this way, you can enjoy Linux distributions not provided in Microsoft Store, as alpine, archilinux, CentOS, Clear Linux OS, etc.

This article introduces step-by-step process about

  1. export from Docker
  2. import to WSL
  3. initial configuration on Clear Linux
  4. run Gnome desktop

Although Linux distribution here is Clear Linux OS, the process should commonly work among other distributions.

Prerequisite

Both WSL2 and Docker Desktop must be installed and executable.
Environment in this article is

FYI, WSL Integration in Docker is not mandatory. In my case, it is OFF.

🔎Docker > Settings > WSL Integration


Export tar file from Docker

Downloading the container image of a target distribution from Docker Hub, and run its container. Then, export it as tar file with specifying NAMES.
Converting these process as commands, it will be as this (See "Commands and Output"). Type and rum them on PowerShell.

🔎Command

docker pull clearlinux
docker run clearlinux
docker container ls -a
docker export --output="clearlinux.tar" angry_bhabha


🔎Output


Import tar file to WSL

Before importing tar file, you should define

Strictly, WSL distributions should be installed to C drive, according to Microsoft.

The Windows Subsystem for Linux only runs on your system drive (usually this is your C: drive). Make sure that distributions are stored on your system drive:

Install WSL | Microsoft Learn
But you can choose the other drive at your own risk. Distributions brought from other than Microsoft Store must be managed only with "wsl" command. To make condition simple and easy, I recommend to install them under simple folder structure as "d:\wsl\[distribution name]".

Following commands import the distribution and register it as "Clear" on WSL.

🔎Command

wsl --import Clear "D:\user temp\wsl\Clear" .\clearlinux.tar
wsl -l -v


🔎Output


Clear Linux configuration by root, and by user

Just after imported, WSL distribution doesn't have user other than root yet. In case of Clear Linux, "sudo" command is not installed.
Register new user and define it as default user in wsl.conf. And install "sudo" command. Converting these process as commands, it will be like this.
In this case, user "wsluser" is registered and its password is also "wlsuser".

🔎Command

useradd wsluser
passwd wsluser
usermod -G wheel -a wsluser
cat << EOF > /etc/wsl.conf
[user]
default=wsluser
EOF
swupd bundle-add sudo
exit

At the 2nd login, you automatically login as "wsluser" in this case. Then Execute following commands to update Clear Linux.

🔎Command

sudo swupd update
exit


🔎Output

Current Clear Linux is its "MINIMUM" condition. To make repeating build & destroy simple and easy, you should keep it as WSL tar file. When importing and register it as the other distribution to WSL, you can reuse it repeatedly without these steps above.
Type following commands from PowerShell.

🔎Command

wsl -t Clear
wsl -l -v
wsl --export Clear E:\WSL\clearlinux.tar


To run Gnome desktop on Clear Linux

X server

With extra steps, you can enjoy GUI on Clear Linux running on WSL. X server must be installed and executable in advance of extra operations. Popular one is as followings.
FYI, I am using MobaXterms. It can cooperate with WSL as terminal and X server is also integrated there.

🔎Popular X server
sourceforge.net
mobaxterm.mobatek.net
x410.dev

Install Bundle

To support GUI, you must install required Bundle (packages). Type following commands in Clear Linux.

🔎Command

sudo swupd desktop
sudo swupd desktop-autostart


After installation is complete, you should logoff and reboot WSL distribution. Then, login again.
🔎Command from PowerShell

wsl -t Clear
wsl -l -v


Set DISPLAY and machine-id

To recognize IP address and screen of X server, you must set "DISPLAY". To dynamically set required information, I put following commands at the end of "~/.profile"
And machine-id, too.

🔎Command

cat << EOF >> ~/.profile
export DISPLAY=$(ipconfig.exe | grep -m 1 IPv4 | awk '{print $14}' | awk 'sub(/\r$/,"")'):0.0
EOF

source ~/.profile
dbus-uuidgen | sudo tee /etc/machine-id


Write script to run GUI

Although gnome-session depends on Systemd, WSL doesn't support it. Following step is for minimum GNOME desktop to directly launch gnome-shell.
To run GUI, commands are also required. To make it single step, write few commands below into a single file as "~/desktop.sh"

🔎desktop.sh

export XDG_CURRENT_DESKTOP="GNOME-Flashback"
gnome-session --session=gnome-flashback-metacity


🔎Command

chmod 777 ~/desktop.sh
~./desktop.sh

Then, you will see the desktop as this.

🔎Gnome on Clear Linux