Showing posts with label IIS. Show all posts
Showing posts with label IIS. Show all posts

Wednesday, April 15, 2020

windows container in docker

One of my tasks is to run Windows containers in docker.
Also, need to manage IIS.
I took part of the code here

The Dockerfile install aspnet windows container with 4.6.2 (because I using old code in my projects), enable in container IIS remote management and binding 443 port with SSL certificate
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.6.2
ARG source
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN Install-WindowsFeature -Name Web-Mgmt-Service
RUN New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WebManagement\Server -Name EnableRemoteManagement -Value 1 -Force
#RUN New-NetFirewallRule -Action Allow -Direction Inbound -DisplayName IISManagement -Service WMSVC
RUN set-service -Name WMSVC -StartupType Automatic
RUN Get-Service -Name WMSVC | Start-Service
RUN net user admin 6H%*!k0*/I /ADD
RUN net localgroup administrators admin /add
#RUN New-WebBinding -Name 'Default Web Site' -IP '*' -Port 443 -Protocol https
RUN $newCert=New-SelfSignedCertificate -DnsName 'localhost' -CertStoreLocation cert:\LocalMachine\My; \
  New-WebBinding -Name 'Default Web Site' -Protocol 'https'; \
  $binding=Get-WebBinding -Name 'Default Web Site' -Protocol 'https'; \
  $binding.AddSslCertificate($newCert.GetCertHashString(),'my')
EXPOSE 80 443
WORKDIR /inetpub/wwwroot
COPY ${source:-obj/Docker/publish} .