@echo off
pushd "%~dp0"
rem Example: docker2wsl ubuntu:latest myubuntu
docker pull %1
docker run -d --name %2 %1 /bin/sh > %TEMP%\ctrid.txt
set /p CTRID= < %TEMP%\ctrid.txt
if exist %TEMP%\ctrid.txt del /f /q %TEMP%\ctrid.txt
docker ps --all --filter id=%CTRID% --format {{.Names}} > %TEMP%\ctrname.txt
set /p CTRNAME= < %TEMP%\ctrname.txt
if exist %TEMP%\ctrname.txt del /f /q %TEMP%\ctrname.txt
echo Distro Name: %CTRNAME%
docker export --output %TEMP%\%CTRID%.tar %CTRID%
mkdir C:\Distro\%CTRID%
wsl --import %CTRNAME% C:\Distro\%CTRNAME% %TEMP%\%CTRID%.tar --version 2
docker rm -f %CTRID%
:exit
popd
@echo on
view raw docker2wsl.cmd hosted with ❤ by GitHub