Skip to content

Instantly share code, notes, and snippets.

@rn
Last active August 29, 2020 10:12
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rn/6bfade1ba98e22691cb287cc8c23609b to your computer and use it in GitHub Desktop.
Save rn/6bfade1ba98e22691cb287cc8c23609b to your computer and use it in GitHub Desktop.
LCOW Linuxkit

Get latest build of dockerd and docker and run dockerd

Invoke-WebRequest -UseBasicParsing -OutFile dockerd.exe https://master.dockerproject.org/windows/x86_64/dockerd.exe
Invoke-WebRequest -UseBasicParsing -OutFile docker.exe https://master.dockerproject.org/windows/x86_64/docker.exe

Add LinuxKit images

Remove-Item "$env:ProgramFiles\Linux Containers" -Force -Recurse
mkdir "$env:ProgramFiles\Linux Containers\"
cp lcow-initrd.img "$env:ProgramFiles\Linux Containers\initrd.img"
cp lcow-kernel "$env:ProgramFiles\Linux Containers\bootx64.efi"

I use RDP to connect to my Windows machine so can use:

Remove-Item "$env:ProgramFiles\Linux Containers" -Force -Recurse
mkdir "$env:ProgramFiles\Linux Containers\"
cp \\tsclient\rneugeba\AAA\lcow-initrd.img "$env:ProgramFiles\Linux Containers\initrd.img"
cp \\tsclient\rneugeba\AAA\lcow-kernel "$env:ProgramFiles\Linux Containers\bootx64.efi"

Start the docker daemon

$env:LCOW_SUPPORTED=1
$env:LCOW_API_PLATFORM_IF_OMITTED="linux"
Remove-Item c:\lcow -Force -Recurse; mkdir c:\lcow
.\dockerd.exe -D --experimental --data-root c:\lcow

or

.\dockerd.exe -D -H "npipe:////./pipe//docker_lcow" --experimental -g c:\lcow

Run client

.\docker run --rm -ti busybox sh

or

.\docker -H "npipe:////./pipe//docker_lcow" run --rm -ti busybox sh

Debugging

Windows Event log:

Get-WinEvent -LogName Microsoft-Windows-Hyper-V-* -MaxEvents 10 | ft -Wrap

hcsdiag.exe to list/login to VMS

Setting:

$env:OPENGCS_DEBUG_ENABLE=1

when the daemon is in debug mode will grab additional logs/output from commands when the utility VMs stop. Additionally setting OPENGCS_DEBUG_COMMAND allows one to specify the commands to execute.

To prevent the LCOW VM from being destroyed:

$registryPath="HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization\Containers\Debug"
New-Item -Path $registryPath -Force | Out-Null
New-ItemProperty -Path $registryPath -Name "PreserveVmOnErrorDestruct" -Value 1 -PropertyType DWORD -Force

and to disable the it:

$registryPath="HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization\Containers\Debug"
Remove-ItemProperty -Path $registryPath -Name "PreserveVmOnErrorDestruct"

Networking debug

cmd /c "netsh trace start globallevel=6 provider={0c885e0d-6eb6-476c-a048-2457eed3a5c1} provider={80CE50DE-D264-4581-950D-ABADEEE0D340} provider={D0E4BC17-34C7-43fc-9A72-D89A59D6979A} provider={93f693dc-9163-4dee-af64-d855218af242} report=di capture=no tracefile=c:\server.etl overwrite=yes"

do stuff and then

netsh trace stop
@funky81
Copy link

funky81 commented Oct 25, 2017

Hi,

May I know, where do you get lcow-initrd.img and lcow-kernel?

cp lcow-initrd.img "$env:ProgramFiles\Linux Containers\initrd.img"
cp lcow-kernel "$env:ProgramFiles\Linux Containers\bootx64.efi"

THanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment