Tag Archives: wsl

Windows: Use Windows WSL openssh client with PuTTY agent

Hi,

newer versions of the PuTTY-CAC agent can act as ssh agent for Windows WSL 1 ssh clients.

Continue reading Windows: Use Windows WSL openssh client with PuTTY agent

Windows WSL: Build/Import a custom linux

Hi,

WSL is not limited to the OS images from the Micosoft store. You can import custom images either when the distributor offers a mini root file system or you can convert docker os images for the import into wsl. This is described in this post.

Requierments are

  • WSL enabled
  • Docker Desktop for Windows installed with the WSL 2 backend engine installed, enabled and checked if the integration works

Installation Docker Desktop for Windows. Download latest version, start installation and ensure “Install requiered Windows Components for WSL2” is selected.

Docker WSL Integration
Docker WSL Integration

Logoff and Logon after installation. Start the Docker Desktop
Start Docker desktop
Start Docker desktop

goto settings and check if wsl2 is enabled
Docker desktop settings
Docker desktop settings



Then go to Resources and select the wsl distributions where docker should be available
Docker WSL Integration into distribution
Docker WSL Integration into distribution

An example:
Start the wsl distribution Ubuntu and check if docker works.

D:\> ubuntu2004
michael@windev:~$ docker --version
Docker version 20.10.10, build b485636

A “service docker start” as describted in the microsoft documentation is not necessary.

Search docker hub for suitable (offical) OS Image. Here Archlinux

WSL Custom Image Archlinux
WSL Custom Image Archlinux

Get the arch linux docker container and start it (see documentation of the vendor)

michael@windev:~$ sudo su
root@windev:/home/michael# docker run -it --name archlinux_export archlinux bash -c ls -l
Unable to find image 'docker:latest' locally
7a147323bccf: Extracting [============>                                      ]  34.54MB/134.3MB
160ee6c41455: Download complete

Get an id from an archlinux container and export the container to one of your Windows drives. Here D:\temp which is mounted under /mnt/d/temp.

root@windev:/home/michael# docker container list --all| grep -i archlinux_export
c50a0039d252   archlinux   "bash -c ls -l"          42 seconds ago   Exited (0) 40 seconds ago
root@windev:/home/michael# docker export c50a0039d252  > /mnt/d/temp/archlinux.tar

Then delete the container and exit wsl

root@windev:/home/michael# docker container rm c50a0039d252   

Back on the windows command try to import the archlinux tar file.

D:\> wsl --import archlinux D:\temp\wsl\archlinux D:\temp\archlinux.tar 

Check the import

D:\> wsl -l --all
archlinux

and start the distibution

C:\Users\Michael>wsl -d archlinux
[root@windev Michael]# cat /etc/issue
Arch Linux \r (\l)

Michael