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=15.1.0.0, 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 4.4.3.5892 to 5.4.0.6315 

  • 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\vimInstall.zip 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
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8-20200211-windowsservercore-ltsc2019

rather than
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8-20200114-windowsservercore-ltsc2019
  • 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

[Environment]::UserName
$env:username
whoami
  • Get all users

PS C:\inetpub\wwwroot> icacls .
. BUILTIN\IIS_IUSRS:(RX)
  BUILTIN\IIS_IUSRS:(OI)(CI)(IO)(GR,GE)
  NT SERVICE\TrustedInstaller:(I)(F)
  NT SERVICE\TrustedInstaller:(I)(OI)(CI)(IO)(F)
  NT AUTHORITY\SYSTEM:(I)(F)
  NT AUTHORITY\SYSTEM:(I)(OI)(CI)(IO)(F)
  BUILTIN\Administrators:(I)(F)
  BUILTIN\Administrators:(I)(OI)(CI)(IO)(F)
  BUILTIN\Users:(I)(RX)
  BUILTIN\Users:(I)(OI)(CI)(IO)(GR,GE)
  CREATOR OWNER:(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

iisreset 

# 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: https://4sysops.com/archives/install-docker-on-windows-server-2019/
# Ref: https://docs.docker.com/ee/docker-ee/windows/docker-ee/
  • 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 https://dockermsft.blob.core.windows.net/dockercontainer/docker-19-03-1.zip -Destination docker-19-03-1.zip

Get-FileHash -Path docker-19-03-1.zip -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"
[Environment]::GetEnvironmentVariable("LCOW_SUPPORTED")

# 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
EXPOSE 80
----------------------


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

155 Comments

2 Trackbacks / Pingbacks

  1. bahis siteleri
  2. 3accoutrements

Leave a Reply

Your email address will not be published.