[Docker] Image2Docker: Bye bye IIS on Windows Server, Hello IIS on Windows Containers

Posted by Florent Appointaire on December 15, 2016
Share on Facebook0Share on Google+0Share on LinkedIn3Share on Reddit21Tweet about this on Twitter0
No ratings yet.

Docker logo


Image2Docker is a tool to convert some Windows Server roles to Docker containers (on Windows, for sure).

With this new version, it’s possible to extract ASP.NET website to run them in containers. To start, I created a VM with 3 ASP.NET websites. This is the view that I have from IIS Manager:

IIS Manager view

And the view from Internet Explorer:

ASP.NET Internet view

Here, we will migrate the WebApiApp website from Windows Server to Windows Container. To start, on the client/server that you’ll use to convert these sites, install the Image2Docker PowerShell Module:

PowerShell script

Following are rules that you can convert from Windows Server to Windows Containers:

PowerShell script

Now, copy the VHD or VHDX where your websites are stored. Execute the following command to extract all website of this VHDX:

PowerShell script

Argument ImagePath contains the path to your VHD/VHDX, the parameter OutputPath is the path where files will be copied and, finally, the parameter Artifact is IIS to specify to check the only website and nothing else. After few moments, your websites are extracted:

GlobalIIS root

As you can see, a Dockerfile appears. This file contains all parameters that are necessary to create a WindowsServerCore image in a container, add IIS features to execute ASP.NET website, copy sources in the right IIS folder of the container and finally, expose the port publicly:

Visual Studio view

I’ll now extract one site, by adding the ArtifactParam parameter, followed by the name of the website:

PowerShell script

Following is the Dockerfile associated, with this time, only one website. This is normal because I asked to extract only the WebApiApp website:

Dockerfile Visual Studio Code

We will now create the docker image based on this Dockerfile. To create the image, move to the folder where is stored the Dockerfile and execute the following command. You can modify the name of the image, which is in my case florentapp/webapiapp:

Command Prompt

Now, create a container from this image. For me, I’ll expose port 8080 that I link with the port 8080 of the website in my container. I’m giving a name to this container webapiapp. The command docker logs gives me the information about logs of the container, and especially the moment that the IIS service is started:

Command Prompt

After that, use the command docker inspect to find the IP address of your container to access the website:

Command Prompt

With Internet Explorer, you can access to your website which is in your container:

ASP.NET web view

On the server which executes the IIS container, you will have a new service running, w3wp, for each IIS container that will be created on this server.

I hope that this example and the script will help you to migrate quickly your websites to Windows Containers.

If you have any questions, don’t hesitate to ping me 🙂

Related materials:

Views All Time
Views Today

Please rate this

To download the software products, please, make your choice below. An installer link and a license key will be sent to the e-mail address you’ve specified. If you consider StarWind Virtual SAN but are uncertain of the version, please check the following document Free vs. Paid. The recent build of Release Notes. A totally unrestricted NFR (Not For Resale) version of StarWind Virtual SAN is available for certain use cases. Learn more details here.

Return to all posts

VMware’s vRealize Log Insight – The easy way to get datacenter insight
Azure Offers now “Bot-as-a-Service” as a new “Serverless” Compute Service
The following two tabs change content below.
Florent Appointaire
Florent Appointaire is Microsoft Engineer with 5 years of experience, specialized in Cloud Technologies (Public/Hybrid/Private). He is a freelance consultant in Belgium from the beginning of 2017. He is MVP Cloud and Datacentre Management. He is MCSE Private Cloud and Hyper-V certified. His favorite products are SCVMM, SCOM, Windows Azure pack/Azure Stack and Microsoft Azure.