Note: This article is only used to discuss asp.net containerization. It is not recommended to use it in production environment (docker image is too large!!!)
Install docker
Prepare a windwindows server 2016, and execute the following fame and fortune in PowerShell
Install-Module DockerProvider -Force
Install-Package Docker -ProviderName DockerProvider -Force
Build a simple website
FROM microsoft/aspnet:4.7.1 COPY ./www/ /inetpub/wwwroot RUN Add-WindowsFeature Web-IP-Security; ` powershell -NoProfile -Command Install-PackageProvider -Name NuGet -MinimumVersio 2.8.5.201 -Force; \ Install-Module -Name IISAdministration -Force; \ net user web 123456 /add ;\ net localgroup administrators web /add RUN powershell -NoProfile -Command \ Import-module IISAdministration ; \ Remove-IISSite -name 'Default Web Site' -Confirm:$false ; \ New-IISSite -Name "www.example.com" -PhysicalPath "C:\inetpub\wwwroot"
1. Install IISAdministration through NuGet, which is an IIS management module. You can manage IIS in the local IIS management container
2. Net user web? Fm9urd? H / add
3.net localgroup administrators web /add set user group
Building HTTPS website
FROM microsoft/aspnet:4.7.1 RUN mkdir /inetpub/tool COPY ./tool/ /inetpub/tool COPY ./www/ /inetpub/wwwroot RUN Add-WindowsFeature Web-IP-Security; ` certutil -importpfx -p "111111" "C:/inetpub/tool/cert.pfx";\ powershell -NoProfile -Command Install-PackageProvider -Name NuGet -MinimumVersio 2.8.5.201 -Force; \ Install-Module -Name IISAdministration -Force; \ net user web 123456 /add ;\ net localgroup administrators web /add RUN powershell -NoProfile -Command \ Import-module IISAdministration ; \ Remove-IISSite -name 'Default Web Site' -Confirm:$false ; \ New-IISSite -Name "www.example.com" -PhysicalPath "C:\inetpub\wwwroot" -BindingInformation "*:443:www.example.com" -CertificateThumbPrint "52C27E02D8EFB1BB488AEC13DB06E94EED18E539" -CertStoreLocation "Cert:\LocalMachine\My" -Protocol https
1.certutil -importpfx -p "password" "C:/inetpub/tool/cert.pfx"; add certificate
2.-CertificateThumbPrint "certificate fingerprint", you can use IIS Manager - > server certificate - > View Certificate - > details - > fingerprint
Build web site with IIS plug-in
FROM microsoft/aspnet:4.7.1 RUN mkdir /inetpub/tool COPY ./tool/ /inetpub/tool COPY ./www/ /inetpub/wwwroot RUN Add-WindowsFeature Web-IP-Security; ` Start-Process ' C:\inetpub\tool\rewrite_amd64.msi' '/qn' -PassThru | Wait-Process;\ powershell -NoProfile -Command Install-PackageProvider -Name NuGet -MinimumVersio 2.8.5.201 -Force; \ Install-Module -Name IISAdministration -Force; \ net user web 123456 /add ;\ net localgroup administrators web /add RUN powershell -NoProfile -Command \ Import-module IISAdministration ; \ Remove-IISSite -name 'Default Web Site' -Confirm:$false ; \ New-IISSite -Name "www.example.com" -PhysicalPath "C:\inetpub\wwwroot"