Stop/Start IIS using host IIS Manager stops container!

From my dockerfile you can see I setup the ability to remotely manage IIS on my container. However, when I stop, then start IIS it stops the container! This doesn’t seem correct…

FROM microsoft/aspnet:4.6.2-windowsservercore

RUN powershell c:\windows\system32\inetsrv\appcmd.exe set config \
-section:system.applicationHost/sites \
/siteDefaults.logFile.directory:“c:\logfiles” /commit:apphost

RUN powershell C:\Windows\System32\inetsrv\appcmd add apppool \
/apppool.name:intbase /managedRuntimeVersion:v4.0 \
/managedPipelineMode:Integrated \
/processModel.identityType:NetworkService \
/enable32bitapponwin64:true

RUN powershell New-Item -ItemType directory -Path C:\sites\intbase

RUN powershell New-Website -Name “intbase” -Port 80 -IPAddress “*” -HostHeader “intbase” -PhysicalPath “C:\sites\intbase” -ApplicationPool “intbase”

RUN powershell c:\windows\system32\dism /online /enable-feature /all /featurename:IIS-ApplicationDevelopment
RUN powershell Install-WindowsFeature -Name Web-Mgmt-Service
RUN powershell Install-WindowsFeature -Name Web-Windows-Auth
RUN powershell Install-WindowsFeature -Name NET-WCF-HTTP-Activation45
RUN powershell Install-WindowsFeature -Name NET-Framework-45-Core
RUN powershell Install-WindowsFeature -Name Web-AppInit
RUN powershell Install-WindowsFeature -Name Web-ASP
RUN powershell Install-WindowsFeature -Name Web-CGI
RUN powershell Install-WindowsFeature -Name Web-Includes
RUN powershell Install-WindowsFeature -Name Web-WebSockets
RUN powershell Install-WindowsFeature -Name Web-Request-Monitor
RUN powershell Install-WindowsFeature -Name WAS-Process-Model
RUN powershell Install-WindowsFeature -Name WAS-Config-APIs

RUN powershell New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WebManagement\Server -Name EnableRemoteManagement -Value 1 -Force
RUN powershell Start-Service -Name WMSVC
RUN powershell net user bktadmin Password1! /ADD
RUN powershell net localgroup administrators bktadmin /add

COPY intbase/ \sites\intbase

EXPOSE 80

Your base image aspnet has an entrypoint defined (ServiceMonitor.exe), this entrypoint monitors the w3svc process. I think what happens is that if you stop IIS then the service monitor stops as well, which means the entrypoint has completed and the container will exit as well.

Probably have to define you own entrypoint that doesn’t exit when IIS is restarted.

  • Johan