microsoft / IIS.ServiceMonitor

An entrypoint process for running IIS in Windows containers
MIT License
126 stars 42 forks source link

Don't fail if DefaultAppPool doesn't exist #39

Closed ghost closed 5 years ago

ghost commented 5 years ago

So i started fiddling around with Azure container instances and it works like a charm with linux container images. But when i try to deploy a windows container instance then the ACI continuously restarts and the state is set to waiting. In logs it says

Service 'w3svc' has been stopped

APPCMD failed with error code 183

Failed to update IIS configuration

The image that i am using is a public image in my docker repo. It has a custom website running inside of it on IIS. Base image was a microsoft/nanoserver . Any help would be much appreciated.

shirhatti commented 5 years ago

@Zuig4turi I don't believe there's anything ACI specific. I successfully deployed the microsoft/iis:nanoserver to ACI earlier this week. That being said, there was an issue in the ServiceMonitor.exe included in the IIS image (prior to July 2017) that failed this exact APPCMD failure due to ServiceMonitor trying to create duplicate environment variables.

Could you retry by rebuilding your image on a newer iis base image?

ghost commented 5 years ago

Hello Shirhatti, When i deploy microsoft/iis:nanoserver as a ACI it works perfectly fine. If i customise the image in anyway it fails. Lets say

docker run -d --name test microsoft/iis:nanoserver docker stop test docker commit test test_v1 docker login docker tag test_v1 reponame:test_v1 docker push reponame:test_v1

Now when i use reponame:test_v1 in ACI it fails, and gives me error

Service 'w3svc' has been stopped

APPCMD failed with error code 183

Failed to update IIS configuration

shirhatti commented 5 years ago

@mcy94w Thoughts on this? This sounds exactly like https://github.com/Microsoft/iis-docker/issues/42 which I believe we'd already fixed a while ago

ghost commented 5 years ago

I kinda solved this issue using a server core image. But nano server images are failing. Anybody who wants to try this, here is what i am doing

docker pull microsoft/iis:nanoserver docker run --name 2048 -d -v C:\2048:C:\data docker exec -i 2048 powershell

inside the container

mkdir C:\sitecontent copy-item C:\data* C:\sitecontent -Recurse Import-Module IIS stop-iissite -name "Default First Site" -confirm:$false remove-iissite -name "Default First Site" -confirm:$false new-iissite -name demosite -physicalpath C:\sitecontent -bindinginformation ":80:"

exit out of the container

docker stop 2048 docker commit 2048 2048_v1 docker login docker tag 2048_v1 :2048_v1 docker push :2048_v1

For the website use any custom content that you might have. Let me know if any nanoserver image works as a ACI image.

Any help will be much appreciated.

shirhatti commented 5 years ago

@Zuig4turi ServiceMonitor will promote environment variables from process environment it's own process environment block to the DefaultAppPool. We achieve this by naively copying all variables in our process environment block.

If you do end up replacing the default site, I'd recommend still using the Default App Pool otherwise you won't get environment variables to work. That being said, we can guard against it which we'll do in a future update

michha commented 5 years ago

@Zuig4turi Since #31 is merged, within the next release of the ServiceMonitor you should be able to remove the DefaultAppPool and get your custom pool monitored

shirhatti commented 5 years ago

@Zuig4turi feel free to re-open if you're still seeing this issue. As far as we're aware, this shouldn't be happening.