-
Notifications
You must be signed in to change notification settings - Fork 256
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
How to create container with runhcs #435
Comments
runhcs.exe isn't really meant to be run by an end user. It is a process with a cmdline but its hard to get all the inputs right by hand. The basic gist is that you need to create a bundle with a C:\> mkdir TestBundle
C:\> notepad TestBundle\config.json Update the C:\> runhcs.exe create -b TestBundle TestContainer
C:\> runhcs.exe start TestContainer
C:\> runhcs.exe kill TestConatiner
C:\> runhcs.exe delete TestContainer Take a look at for a simple example of how our tests do it: https://github.com/Microsoft/hcsshim/blob/master/test/runhcs/e2e_matrix_test.go#L165 |
Thanks @jterry75 I got it working :) As info for anyone who might read this. Template config can be found from: https://github.com/Microsoft/hcsshim/blob/d0b3bfc2ea9303a6a506da319f67fe827530b91e/test/functional/assets/defaultwindowsspec.json#L1-L11 It is easiest play with this is use machine where you have only one image. Then you can detect layers on C:\ProgramData\Docker\windowsfilter folder on way that (at least on case nanoserver):
Before you can create container you need create new layer which is based on scratch layer. You can do that with command: After that you can use commands above. Btw. I got same |
Here is also fully working PowerShell script which does all needed steps. # Settings
$ImageTag = "microsoft/nanoserver:latest"
$BundleName = "TestBundle"
$ContainerName = "TestContainer"
##########################################
$DockerImage = docker images -q $ImageTag
if (!($DockerImage)) { throw "Cannot find image: $ImageTag" }
$ImageInspect = docker image inspect $ImageTag | ConvertFrom-JSON
$BaseLayer = $ImageInspect.GraphDriver.Data.dir
$ScratchLayer = Get-Content "$BaseLayer\layerchain.json" | ConvertFrom-Json
cd $PSScriptRoot
$BundlePath = "$PSScriptRoot\$BundleName"
New-Item -ItemType Directory -Path $BundleName
.\wclayer.exe create --layer $ScratchLayer $BundleName
$Config = @"
{
`"ociVersion`": `"1.0.1`",
`"process`": {
`"args`": null,
`"env`": [],
`"cwd`": `"c:\\`",u
`"args`": [
`"cmd`"
]
},
`"windows`": {
`"layerFolders`": [
`"$($ScratchLayer -replace '\\','\\')`",
`"$($BundlePath -replace '\\','\\')`"
]
}
}
"@
$Config | Out-File -Encoding ASCII -FilePath "$BundlePath\config.json"
.\runhcs.exe create -b $BundleName $ContainerName
.\runhcs.exe list
.\runhcs.exe start $ContainerName
Start-Sleep -Seconds 5
.\runhcs.exe kill $ContainerName
.\runhcs.exe delete $ContainerName |
I have been tracking down moby/moby#30950 to hcsshim and I would like to be try if same issue happens with runhcs.
I have broken Windows Server 2016 where even just build version of moby gives this error when I'm trying to start new container (with command
docker run -it --rm microsoft/nanoserver cmd
):But actually do that with runhcs.exe?
The text was updated successfully, but these errors were encountered: