How To Create an IIS Website with DockerFile

In this blog post, I’ll show you how I deploy an IIS Website Image automatically by reading and executing Instructions from a dockerFile.

Docker can build images automatically by reading the instructions from a Dockerfile and apply them to the Image In real time, once completed we have a complete Image.

A Dockerfile is a text document that contains all the commands an admin will use to deploy and Image.

In my case, I’ll deploy and IIS Website Image with all the configuration listed in the dockerFile, Including copying the Website content from the file and Installing IIS.

About Docker

Docker provides an additional layer of abstraction and automation of operating-system-level virtualization on Windows and Linux.

It also uses the resource isolation features of the Linux kernel such as cgroups and kernel namespaces, and a union-capable file system such as OverlayFS and others to allow independent “containers” to run within a single Linux instance, avoiding the overhead of starting and maintaining virtual machines (VMs).


Below, I have my dockerfile with Instructions to deploy Windows Server Core 2016 Image, Install IIS and copy the Website content to IIS.

FROM microsoft/windowsservercore

RUN powershell.exe

RUN powershell.exe Add-WindowsFeature web-server, web-webserver

COPY /online/* c:/inetpub/wwwroot

Once, I have the dockerfile configure, I’ll save it without any extension and place it In a folder called IISSITE.

From the IISSITE folder I’ll run the cmdlet below which will build the Image using the commands In the dockerFile.

docker build -t iissite .

Once the image is completed successfully I’ll create a new containers using the Image.

docker run -it --network=lan iissite

As you can see my website is up and running in a matter of seconds and I don’t need to install or configure anything on the container.


DockerFile is the recommended method to deploy images and then run the containers simply because we don’t need to run any cmdlets or configuration and the container.