In this blog post, I’ll show you how to port Windows Server IIS applications or Sites to windows Containers using image2docker.
The tool Image2docker, Is a PowerShell Module that ports Windows Server IIS and ASP.NET applications from a .VHD, .VHDX or .WIN files to a Docker container Image.
The focus of the module Is to port IIS and ASP.NET applications to docker however the tool supports other roles as well.
The only requirement for Image2Docker Is to have PowerShell 5.0 Installed on the machine you will port the applications, There is no need to install docker on the machine.
To Install Image2Docker I’ll open PowerShell and run the cmdlet below:
To view all cmdlets In the module, I use:
Get-Command -Module Image2Docker
Once, Installed I can view all available applications I can port to Docker using the line below:
Below, I’ll run a cmdlet that will port IIS sites to a Docker Image:
ConvertTo-Dockerfile -ImagePath .\VDC02.vhdx -Artifact IIS -OutputPath c:\vh\VDC02
Note: It’s recommended to us the -Artifact switch to tell the module what we want to port, Otherwise the module will scan the entire VM for everything that can be ported.
Once done, I’ll see the files below In the Output folder, and you can see below that I have a DockerFile and a wwwroot folder for my IIS website
Now, all I need to do Is build my Docker Container Image using the line below:
Docker build -t vdc02 .
The process will take a few minutes depending on the size of the Image
When done, I’ll see the Image
Next, I’ll create a new Container and I’m done
To view that my IIS site Is running I’ll use docker exec to check If the site Is running
Docker exec 6f61eb8cdc2d powershell get-iissite
Image2Docker Is great tool that can port existing IIS and .NET application to Docker easily.
My recommendation Is to use the tool for simple and basic application before moving to more complex applications.