IIS Remote Management for Docker Containers

Premier Developer

Developer

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.

6 comments

Comments are closed. Login to edit/delete your existing 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)

  • Avatar
    Panayiotis Savva

    I have followed the exact steps as suggested in this blog, with error:

    When trying to Connect to the Server, and once Prompted for the username and password, i enter those, and click Next.
    An error message is returned by to the IIS Manager : “Could not connect to the specified computer. Details: The underlying connection was closed: An unexpected error occured on a receive.”

    • Richard Nunez
      Richard Nunez

      To fix the connection issue be sure to expose port 8172 to the host. IIS Management Services uses port 8172 to communicate. I did that and now I can connect to the container’s IIS Manager as above.

  • Avatar
    Austin Craft

    When trying to install IIS Manager for Remote Administration 1.2 with the provided link, I get the following error

    We're sorry, this download is no longer available.

    Can you advise?

    • Avatar
      Daniel Dietze

      Seems like MS has changed his download site and removed it 🙁
      I was also not able to install it from the web plattform installler :/

      DownloadManager Error: 0 : Error while downloading file ‘http://download.microsoft.com/download/2/4/3/24374C5F-95A3-41D5-B1DF-34D98FF610A3/inetmgr_amd64_en-US.msi’. Exception: System.Net.WebException: Url ‘http://download.microsoft.com/download/2/4/3/24374C5F-95A3-41D5-B1DF-34D98FF610A3/inetmgr_amd64_en-US.msi’ returned HTTP status code: 404
      at Microsoft.Web.PlatformInstaller.ManagedWinInet.OpenUrlAndFollowRedirects(Uri& uri, IntPtr& hInetFile)
      at Microsoft.Web.PlatformInstaller.ManagedWinInet.DownloadFile(Uri uri, String fileName, String& contentDispositionFileName)
      at Microsoft.Web.PlatformInstaller.InstallManager.WinInetDownloadInstallerFile(InstallerContext currentInstall, String& failureReason)

      :/

      Maybe you are able to find it in an msdn download oder enterprise download portal from microsoft.