This post will walk you through, how I have built my first Docker container.

Prepare the environment

If you already have Windows 10 or Windows server 2016 machine. Download code to configure Docker environment.

If you would like to have a new VM Get the code from here. This will create Windows server 2016 VM with Docker, VS Code, git and chrome.

Let’s discuss some basic docker commands, before we start

Let’s create our first windows container

To start with VS Code, Install Docker extension. In addition to this you can also install the PowerShell, Azure Resource Manager Tools extensions.

Docker Extension in VS Code

Lab 1 - Objective

  • Step 1: Create docker file and use default IIS server image from docker hub.
  • Step 2: Build container
  • Step 3: Run container

let’s run some basic command

docker images

docker ps

docker ps -a

Step 1: Dockerfile

  • Create a folder - Demo
  • Open this folder in VS Code
  • Create a file without extension (file name - dockerfile) and save it.

Docker Extension in VS Code

FROM microsoft/iis

LABEL Author="Ajeet Chouksey"


CMD ["ping localhost -t"]


The FROM instruction initializes a new build stage and sets the Base Image for subsequent instructions. As such, a valid Dockerfile must start with a FROM instruction.

Refer Docker HUB, and search for available images.


The LABEL instruction adds metadata to an image. A LABEL is a key-value pair. To include spaces within a LABEL value, use quotes and backslashes as you would in command-line parsing. An image can have more than one label. You can specify multiple labels on a single line.

LABEL Author="Ajeet Chouksey"


LABEL Author="Ajeet Chouksey" \


The EXPOSE instruction informs Docker that the container listens on the specified network ports at runtime. You can specify whether the port listens on TCP or UDP, and the default is TCP if the protocol is not specified.

The EXPOSE instruction does not actually publish the port. It functions as a type of documentation between the person who builds the image and the person who runs the container, about which ports are intended to be published. To actually publish the port when running the container, use the -p flag on docker run to publish and map one or more ports, or the -P flag to publish all exposed ports and map them to high-order ports.


The main purpose of a CMD is to provide defaults for an executing container.

docker build -t <<name>> .

Step 2: BUILD

The docker build command builds Docker images from a Dockerfile and a “context”. A build’s context is the set of files located in the specified PATH or URL. The build process can refer to any of the files in the context. For example, your build can use a COPY instruction to reference a file in the context.

Docker Build

Docker Build


Docker PS

Step 3: RUN

docker run -d demo <<>>

Docker run -d

Let’s run the following command

docker run -it -p 80:80 demo
docker run -it -p 80:80 demo powershell

in next post, we will build and run the container and try to customize IIS site. We will also use the Azure Container Registry and Azure Container Instance to host and run the container.

Please do let me know your thoughts/ suggestions/ question in disqus section.

Related Posts

About Ajeet Chouksey

As Technology Architect, Ajeet has over 12+ years of industry experience delivering enterprise solutions on the Microsoft Platform. Ajeet is passionate, certified technologist, blogger and community contributor. His specialisms are Azure IaaS/PaaS, Automation, DevOps, Agile based development processes supporting distributed teams (on shore & off shore), designing and implementing the appropriate infrastructure and platform solutions to meet the functional, operational, and deployment requirements throughout the solution life-cycle. Ajeet is member of various technical communities and discussion groups. He also conducted many boot camps on Azure and DevOps.