Windows Container FAQ (updating)

  • Keep pod running (alive)

command: ["ping", "-t", "localhost"]
  • Nuget restore fail

    • error:

nuget restore Src\GICG.sln -MSBuildPath "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin" 15:40:52 Using Msbuild from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin'. 15:40:52 Error parsing solution file at xxx.sln: Exception has been thrown by the target of an invocation. The project file could not be loaded. Could not load file or assembly 'Microsoft.Build.Framework, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. xxx.sln
    • Solve: update NuGet.exe CLI tool from to 

  • Chocolatey error installing vim and made2010 in base image ‘aspnet:4.8-20200114-windowsservercore-ltsc2019’

    • Error:

15:15:37 Installing made2010...
15:15:42 ERROR: Running ["C:\Users\ContainerAdministrator\AppData\Local\Temp\chocolatey\made2010\2016.07.01\AccessDatabaseEngine_X64.exe" /quiet /norestart ] was not successful. Exit code was '-1073741502'. See log for possible error messages.
15:15:42 The install of made2010 was NOT successful.
13:53:44 Extracting C:\Users\ContainerAdministrator\AppData\Local\Temp\vim\8.2.0374\ to C:\tools...
13:53:45 ERROR: 7-Zip signalled an unknown error (code -1073741502) This is most likely an issue with the 'vim' package and not with Chocolatey itself. Please follow up with the package maintainer(s) directly.
    • Solve:  

# Use base image with

rather than
  • Windows Server 2016 與 Windows 10 上的 Windows Container

    • 透過 docker info 指令可以看到 docker 相關設定

    • * 預設 Docker 使用路徑

      • C:\ProgramData\dcoker

    • * 預設 image 儲存資料夾

      • windowsfilter

    • * 修改儲存路徑

    •     1. 在 C:\ProgramData\Docker\config 新增 daemon.json

    •     2. 修改 daemon.json 指定儲存路徑 {“graph”: “C:\\Docker”}

    •     3. 重新啟動 docker 服務

    •         * 使用 powershell 執行指令

        • restart-service *docker*

  • Grant permission to folder

# At version ltsc2019 - 10.0.17763 N/A Build 17763

## Work
RUN icacls 'C:\Memo\' /grant 'IIS_IUSRS:(OI)(CI)F' /T

## Not work
RUN icacls 'C:\Memo\' /grant "IIS_IUSRS":(OI)(CI)F /T
RUN icacls 'C:\Memo\' /grant "IIS_IUSRS:(OI)(CI)F" /T
  • Get current user

  • Get all users

PS C:\inetpub\wwwroot> icacls .
  NT SERVICE\TrustedInstaller:(I)(F)
  NT SERVICE\TrustedInstaller:(I)(OI)(CI)(IO)(F)

Successfully processed 1 files; Failed processing 0 files
  • Grant permission by icacls on OS version 10.0.17763 (ltsc2019)

    • error msg: 

      • Invalid parameter “‘IIS_IUSRS:(F)'”

      • C:\inetpub\wwwroot” /grant IIS_IUSRS:f: The filename, directory name, or volume label syntax is incorrect.

    • solution:

RUN icacls C:\inetpub\wwwroot\ /grant "IIS_IUSRS:(F)"
  • Fail to grant permission to folder on OS version 10.0.17763;  should use 10.0.18362

icacls '\inetpub\wwwroot\' /grant 'IIS_IUSRS:(F)'
    • Failed at OS:

PS C:\> systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
OS Name:                  Microsoft
OS Version:                10.0.17763 N/A Build 17763
    • Passed at OS:

PS C:\> systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
OS Name:                  Microsoft
OS Version:                10.0.18362 N/A Build 18362
  • Copy file to image

docker cp index.html datatest1:c:\inetpub\wwwroot
  • Restart IIS


# Need stop it first
net start/stop w3svc
  • Error pulling image from private repo, after new namespace created

Ask for setting
  • Error response from daemon: removal of container xxx is already in progress

#for Windows:
del D:\ProgramData\docker\containers\{CONTAINER ID}
del D:\ProgramData\docker\windowsfilter\{CONTAINER ID}
#Then restart the Docker Desktop
  • Grant permission to IIS user

    • Error:

"InnerException":{"Message":"An error has occurred.","ExceptionMessage":"Access to the path 'C:\\inetpub\\wwwroot\\App_Data\\BodyPart_481b6424-f9a5-4608-894d-406145a48445' is denied.","ExceptionType":"System.UnauthorizedAccessException"
    • Solve:

--- Dockerfile ---
RUN icacls 'C:\inetpub\wwwroot\XXX' /grant 'IIS_IUSRS:(F)'
  • Install docker on Windows Server 2019 – native installer

# Run PowerShell As Admin!!! (important)

Install-WindowsFeature containers -Restart
Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
Install-Package -Name docker -ProviderName DockerMsftProvider
Start-Service Docker

# Ref:
# Ref:
  • Install docker on Windows Server 2019 – manual – unsuccessful

# Path refer to the error message
# Version refer the latest version

cd C:\Users\Administrator\AppData\Local\Temp\DockerMsftProvider

Start-BitsTransfer -Source -Destination

Get-FileHash -Path -Algorithm SHA256

Install-Package -Name docker -ProviderName DockerMsftProvider -Verbose

Restart-Computer -Force
  • Uninstall docker on Windows Server 2019 – native installer

Uninstall-Package -Name docker -ProviderName DockerMsftProvider
Uninstall-Module -Name DockerMsftProvider
  • Install docker preview (support linux container) in Windows Server 2019  ref

# Enable Nested HyperV and install HyperV first
Uninstall-Package -Name docker -ProviderName DockerMSFTProvider
Install-Module DockerProvider
Install-Package Docker -ProviderName DockerProvider -RequiredVersion preview
  • Switch docker OS

# Get current container OS "1: linux; null: Windows"

# Switch to linux container
[Environment]::SetEnvironmentVariable("LCOW_SUPPORTED", "1", "Machine")
Restart-Service docker
# Switch to Windows container
[Environment]::SetEnvironmentVariable("LCOW_SUPPORTED", $null, "Machine")
Restart-Service docker
  • Size of images

Oct '18

microsoft/windowsservercore latest f8dc15f55717 12 days ago 10.9GB
microsoft/nanoserver latest 4c872414bf9d 12 days ago 1.17GB
microsoft/aspnet latest 02dfa1e1baeb 5 weeks ago 13.6GB
nanoserver/iis latest 7eac2eab1a5c 4 months ago 1.29GB
  • Quick start running a windows container app

----- Dockerfile -----
# The `FROM` instruction specifies the base image. You are
# extending the `microsoft/aspnet` image.

FROM microsoft/aspnet

# The final instruction copies the site you published earlier into the container.
COPY ./bin/Release/PublishOutput/ /inetpub/wwwroot

docker build -t mvcrandomanswers .
docker run -d --rm -p 8000:80 --name randomanswers mvcrandomanswers

docker tag mvcrandomanswers xx.registry/xx_project/mvcrandomanswers:latest
docker push xx.registry/xx_project/mvcrandomanswers:latest


發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *