Created
October 25, 2020 16:50
-
-
Save rkttu/c45c1831a8a3cd4c359193ce593311df to your computer and use it in GitHub Desktop.
Docker container to WSL convert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment