IIS Remote Management for Docker Containers

Premier Developer

Premier

Premier Developer Consultant Randy Patterson walks use through IIS remote management for Docker containers.


When running IIS in a Windows Container, you configure it using PowerShell commands in your Dockerfile. While determining the correct PowerShell commands is not a difficult process it is inconvenient to verify the settings using the command line only. Sometimes, you just need a UI to quickly view and manage your IIS configuration.

Fortunately, Internet Information Services (IIS) Manager for Windows allows remote management of IIS server including running in a container. However, it is not enabled by default for Windows Containers.

Required Steps:

  1. Enable Remote Management in the Docker image
  2. Add an Admin user to the container image to allow IIS Remote Manager to login
  3. Connect to container using IIS Remote Manager

Enable Remote Management in the Docker Image

The first step to enable remote management is to install the Web-Mgmt-Service and configure it to automatically start when the container starts. Additionally, an admin user needs to be added to the container to allow the Remote IIS Manager UI to remotely connect and manage IIS

FROM microsoft/iis

SHELL [ "powershell" ]

#setup Remote IIS management

RUN Install-WindowsFeature Web-Mgmt-Service; \

New-ItemProperty -Path HKLM:\software\microsoft\WebManagement\Server -Name EnableRemoteManagement -Value 1 -Force; \

Set-Service -Name wmsvc -StartupType automatic;

#Add user for Remote IIS Manager Login

RUN net user iisadmin Password~1234 /ADD; \

net localgroup administrators iisadmin /add;

Step 1: Create an image using the above Dockerfile

docker build -t iisremote .

C:\Users\ranpat\AppData\Local\Temp\SNAGHTML1e5790f2.PNG

Figure : Build Image Sample Output

Step 2: Start the container

docker run --name remoteiis -d iisremote

Step 3: Display the IP Address of the running container

docker inspect --format '{{ .NetworkSettings.Networks.nat.IPAddress }}' remoteiis

Connect to IIS running in the container

Finally, start IIS Manager then right click on Start Page and click Connect to Server

E:\SystemTemp\SNAGHTML202db6db.PNG

If you do not have a “Start Page” or “Connect to Server” then install the IIS Remote Manager Plugin located here https://www.iis.net/downloads/microsoft/iis-manager

Enter the IP Address from Step 3 above

Next, enter the Remote IIS Manager Login from the Docker file in Step 1 above. The default is iisadmin/Password~1234

If you get a certificate warning, click Connect

On the next dialog, keep the default connection name and press the Finish button. You can now use IIS Manager to remotely configure IIS running in a container.

Premier Developer
Premier Developer

Premier Support for Developers

Follow Premier   

2 comments

  • Avatar
    Brett Hinton

    While I appreciate the convenience here and I could see some use cases around immediate mitigation of an issue followed by a longer term fix, if we think about containers as immutable outputs of a solution, using this solution feels like something of an anti-pattern. I must be missing the main use case here (perhaps the initial development of a solution in a container). Wouldn’t this basically allows to start turning our containers into pets (instead of cattle) which wouldn’t make them much different than the modern day VM (if a little lighter weight I suppose)

Leave a comment