none
Can't run PowerShell command in Nano Server container image on WS2019 Datacenter RRS feed

  • Question

  • Hi,

    I am trying to launch a simple container on Windows Server 2019 Datacenter (version 1809 on Azure) with this Dockerfile:

    FROM mcr.microsoft.com/windows/nanoserver:1809
    COPY hello.ps1 c:\\hello.ps1
    CMD ["powershell.exe", "c:\\hello.ps1"]

    When I run the container, I get this error message:

    docker : C:\Program Files\Docker\docker.exe: Error response from daemon: container 
    93813c973f991d390b566448a4a632a855487dcd680a75af6ac145cdcb813a9a encountered an error during CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2) extra info: {"CommandLine":"powershell.exe c:\\hello.ps1"
    ,"User":"ContainerUser","WorkingDirectory":"C:\\","EmulateConsole":true,"CreateStdInPipe":true,"CreateStdOutPipe":true,"Console
    Size":[0,0]}.
    At line:1 char:1
    + docker run -i -t wcnano-ps
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (C:\Program File...leSize":[0,0]}.:String) [], RemoteException
        + FullyQualifiedErrorId : NativeCommandError

    If I build the image with the Server Core image (FROM mcr.microsoft.com/windows/servercore:1809), the container runs correctly. Is PowerShell not included in the Nano Server image, or do I need to use a different syntax in the Dockerfile when using that image?

    Sunday, January 13, 2019 6:27 PM

All replies

  • Microsoft removed powershell and other pieces from base nanoserver image. You need to use image with built in poweshell. For some reason there is no published image for 1809. Not sure what the reason is. Based on github repo, there were some breaking changes which were incporated into code just 5 days ago. 

    https://github.com/PowerShell/PowerShell-Docker/tree/master/release/stable

    Here is why 

    https://github.com/PowerShell/PowerShell-Docker/pull/118


    Sunday, January 13, 2019 9:17 PM
  • Microsoft removed powershell and other pieces from base nanoserver image. You need to use image with built in poweshell. For some reason there is no published image for 1809. Not sure what the reason is. Based on github repo, there were some breaking changes which were incporated into code just 5 days ago. 

    https://github.com/PowerShell/PowerShell-Docker/tree/master/release/stable

    Here is why 

    https://github.com/PowerShell/PowerShell-Docker/pull/118


    Will one day they'll return Powershell 5.1 to the nanoserver?

    Monday, January 14, 2019 11:22 PM
  • Not in base image since they want to keep base image as small possible to compete with Linux
    Monday, January 14, 2019 11:23 PM
  • Now you can use a powershell core + nanoserver image; as today (august, 2019) you can get the pscore from:  mcr.microsoft.com/powershell

    For instance, I use to run the following command to get it running: 
    docker run -it mcr.microsoft.com/powershell:preview-nanoserver-1803 pwsh.exe 


    Paulo 


    Sunday, August 11, 2019 1:06 AM