How to manage site in iis container using iis manager on the host windows server 2016

I deployed a iis container in my windows server 2016. When I try to connect to the container using iis manager on the container host, I am not able to connect to it. Kindly give me steps to connect to iis using iis manager to mange the site in container.

Hi vishnugillela,
I had the same question of yours and I did this to solve…

First, get into container with Powershell, then use it to install IIS and IIS Management Tools:

Install-WindowsFeature -name Web-Server -IncludeManagementTools

After that, you install IIS Management Service using DISM:

Dism /online /enable-feature /featurename:IIS-ManagementService /all

And then you can enable remote access:
New-ItemProperty -Path HKLM:\software\microsoft\WebManagement\Server -Name EnableRemoteManagement -Value 1 -Force

Stop and start services:

net stop Iisadmin && net stop W3svc && net stop wmsvc
net start Iisadmin && net start W3svc && net start wmsvc

To connect you need to get the container IP:

docker inspect --format ‘{{ .NetworkSettings.IPAddress }}’ your_container_id

So you can connect using IIS Manager console from your host using the IP you got :slight_smile:

It worked for me, hope it help you! :wink:

1 Like

Might be a bit late, but encountered the same issue, and for reference as well. I was able to solve it by putting these lines inside my Dockerfile (of course base image should be windows container with IIS)

RUN powershell Install-WindowsFeature -Name Web-Mgmt-Service
RUN powershell New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WebManagement\Server -Name EnableRemoteManagement -Value 1 -Force
RUN powershell Get-Service -Name WMSVC | Start-Service
RUN powershell net user <username> <password> /ADD
RUN powershell net localgroup administrators <username> /add

Alternatively, run those commands inside the container using powershell.

Then with my IIS, add connection in the connection pane, enter the container’s IP address, and use the you provided in the Dockerfile above.

You should be able to remote the container’s IIS using your machine’s IIS manager.

Hope this helps as well.

1 Like

Hello @janjulienn,
I get this error when I run that command inside my Dockerfile. Please help.

‘Start-Service’ is not recognized as an internal or external command,
operable program or batch file.
ERROR: Service ‘iis’ failed to build: The command ‘cmd /S /C powershell Get-Service -Name WMSVC | Start-Service’ returned a non-zero code: 255

What is your base image?

FROM microsoft/windowsservercore

What your dockerfile contains? I don’t see any Start-Service entries above.

escape=`

FROM microsoft/windowsservercore

RUN powershell -Command Add-WindowsFeature Web-Server;
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
Invoke-WebRequest -UseBasicParsing -Uri “https://dotnetbinaries.blob.core.windows.net/servicemonitor/2.0.1.3/ServiceMonitor.exe” -OutFile “C:\ServiceMonitor.exe”

RUN powershell Install-WindowsFeature -Name Web-Mgmt-Service
RUN powershell New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WebManagement\Server -Name EnableRemoteManagement -Value 1 -Force
RUN powershell Get-Service -Name WMSVC | Start-Service
RUN powershell net user admin Rlink123 /ADD
RUN powershell net localgroup administrators admin /add

EXPOSE 80

ENTRYPOINT [“C:\ServiceMonitor.exe”, “w3svc”]

Put this directly under escape and remove all references to powershell.

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

Here is step by step with everything written in powershell

Thank you for your reply, the step above is throwing another error FYI.

-Command : The term ‘-Command’ is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.
At line:1 char:76

  • … = ‘Stop’; $ProgressPreference = ‘SilentlyContinue’; -Command Add-Win …
  •                                                      ~~~~~~~~
    
    • CategoryInfo : ObjectNotFound: (-Command:String) [], ParentCont
      ainsErrorRecordException
    • FullyQualifiedErrorId : CommandNotFoundException

What is your dockerfile looks like

Never mind, remove everything relevant to powershell including command. So it will be just RUN Add-WindowsFeature

escape=`

FROM microsoft/windowsservercore

SHELL [“powershell”, “-Command”, “$ErrorActionPreference = ‘Stop’; $ProgressPreference = ‘SilentlyContinue’;”]

RUN -Command Add-WindowsFeature Web-Server; `
Invoke-WebRequest -UseBasicParsing -Uri “https://dotnetbinaries.blob.core.windows.net/servicemonitor/2.0.1.3/ServiceMonitor.exe” -OutFile “C:\ServiceMonitor.exe”

RUN Install-WindowsFeature -Name Web-Mgmt-Service
RUN New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WebManagement\Server -Name EnableRemoteManagement -Value 1 -Force
RUN Get-Service -Name WMSVC | Start-Service
RUN net user admin Rlink123 /ADD
RUN net localgroup administrators admin /add

EXPOSE 80

ENTRYPOINT [“C:\ServiceMonitor.exe”, “w3svc”]

Ok I will try that THANKS!!!

Remove -Command in RUN statement and replace net user etc with equivalent POwershell commands

Apparently Powershell was able to understand the net user and net localgroup :smiley: Thank you @artisticcheese. It worked

Yes, it would but it’s classy to stop using cmd and use powershell for everything

Great. This worked for me.

ı followed your advices and everything was ok. My ımage has builded than container is up. I also check the web Api on url it was up too… bu when I tried to connect on admin console with my container ip and port number , and my username and password which I specified on Dockerfile . I coulnot connect to server .