How To Build A Windows Server Container Image From A Dockerfile

In this blog post, I’ll show you how to create a basic Windows Container Image from a dockerFile using a Windows Nano Server Container Image.

What Is DockerFile

DockerFile Is a file without extension (based on Linux) that contains Instructions that are used to build Container Images.

To create the most basic docker file you will need to use only one line (From).

Create Folder

To create an Image from a DockerFile, I’ll create an empty folder on my C: Drive and will store the DockerFile.

Create a DockerFile

Next, I’ll create my dockerFile with all my Instructions and I’ll save it without any extension Inside the folder I created before.

In the file below, I’m creating a basic Docker Container Image made of Nano Server and mounting a volume Inside the Container.

FROM microsoft/nanoserver

VOLUME web001:c:\\data

Running the DockerFile

To run my DockerFile, I’ll run the docker command below from the folder I created with the dockerFile Inside.

docker build --tag image101 .

Once the build process Is done, I can see the new Image using the command below

Docker Image

To run a new container from the new Image I’ll use the command below

docker -rm -it image101 powershell

Inside the container, I can see the data folder which Is mounted to the c:\data Inside the container

Leave a Reply

Your email address will not be published. Required fields are marked *