0

I am working on trying to run the dotnet/core/sdk container in Azure Pipelines. To get everything lined up, I built a PowerShell script that effectively pulls the container and drops the necessary files inside it before running it:

$compositeImage = "mcr.microsoft.com/dotnet/core/sdk:3.0.100-preview4-nanoserver-1809"
docker pull $compositeImage

$targetContainer = ""

Write-Host "Creating container for pre-provisioning..."

($targetContainer = docker create --name builder $compositeImage)

Write-Host $targetContainer

docker ps -a
Write-Host "Copying samples to container..."
$workPath = "C:\Users\dendeli\Documents\Expression"
$scriptPath = "C:\Users\dendeli\Downloads\test2\test2.ps1"

Write-Host "Samples path: " + $workPath
Write-Host "Script path:" + $scriptPath

Write-Host "Executing copy..."
docker cp $workPath builder:__samples

Write-Host "Executing script copy..."
docker cp $scriptPath builder:buildsamples.ps1

Write-Host "Committing changes..."
docker commit builder "mcr.microsoft.com/dotnet/core/sdk"

docker run --name newbuilder --rm "mcr.microsoft.com/dotnet/core/sdk" powershell

The issue comes at the end, when I am executing docker run. If I exclude the command to be passed (powershell), it all works fine and I see this output:

Microsoft Windows [Version 10.0.XYZ]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\>

However, with the command appended, I am running into a blocker - it errors out:

C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: container 879f2fff5aeaf19ace367d3f713242519238a96944b35b2598f2a3b6010a19fb encountered an error during CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2)
[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail: onecore\vm\compute\management\orchestration\vmhostedcontainer\processmanagement.cpp(173)\vmcomputeagent.exe!00007FF686739ADB: (caller: 00007FF6866EDF1A) Exception(2) tid(380) 80070002 The system cannot find the file specified.
    CallContext:[\Bridge_ProcessMessage\VmHostedContainer_ExecuteProcess]
 Provider: 00000000-0000-0000-0000-000000000000] extra info: {"CommandLine":"powershell","User":"ContainerUser","WorkingDirectory":"C:\\","Environment":{"ASPNETCORE_URLS":"http://+:80","DOTNET_RUNNING_IN_CONTAINER":"true","DOTNET_USE_POLLING_FILE_WATCHER":"true","NUGET_XMLDOC_MODE":"skip"},"CreateStdInPipe":true,"CreateStdOutPipe":true,"CreateStdErrPipe":true,"ConsoleSize":[0,0]}.

What am I missing here?

Den
  • 16,686
  • 4
  • 47
  • 87
  • @HAL9256 the `run` command will need to instantiate a new container, with a different name, so the unique name should generally not be the blocker. – Den May 05 '19 at 02:00
  • 1
    ok thanks. I haven't had the opportunity to work with docker so I thought it might have been an easy fix ;-) – HAL9256 May 05 '19 at 02:03

1 Answers1

3
C:\> docker container run -it --rm mcr.microsoft.com/dotnet/core/sdk:3.0.100-preview4-nanoserver-1803

Microsoft Windows [Version 10.0.17134.706]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\>powershell
'powershell' is not recognized as an internal or external command,
operable program or batch file.

For Powershell 5.1 you'll need the net framework to run it, which wouldn't make sense in a container hosting dotnet core.

pwshworks ( Powershell Core).

C:\>pwsh
PowerShell 6.2.0
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

PS C:\>
Moerwald
  • 10,448
  • 9
  • 43
  • 83