Creating a Windows Server container image begins with writing a Dockerfile, which is a script of instructions that tells Docker how to build the image. The first directive chooses a base image, such as Windows Nano Server, which provides a lightweight operating system layer. Each directive adds a new layer to the image, so managing layers carefully keeps the final image small. Multi‑stage builds help with this: the first stage installs build tools and compiles code, and the second stage copies only the compiled output into a fresh, smaller base image. This way the final image contains only what is needed to run the application, not the temporary tools used during compilation.
After the Dockerfile is written, the docker build command turns it into an actual image. You specify the Dockerfile with the -f flag and give the image a name and tag. For example:
docker build -f Dockerfile.windows -t myregistry.azurecr.io/myapp:1.0 .
The dot at the end tells Docker to use the current directory as the build context, which includes all files the Dockerfile might copy into the image.
Before publishing, you often tag the image with a meaningful version or label using docker tag. The image must then be stored in a registry so it can be pulled later for deployments. For Azure, the registry is Azure Container Registry (ACR). To push the image, you first log in to Azure and to ACR:
az login
az acr login -n your_registry_name
Then use docker push to upload the image:
docker push your_registry_name.azurecr.io/myapp:1.0
The push command sends the image layers to ACR, making it available across Azure regions and services.
After publishing, you should test the image in a real deployment environment. Deploy a container instance using the image, monitor its logs, and check that it behaves correctly. If problems appear, update the Dockerfile (for example, by changing a base image or adding missing dependencies) and rebuild the image. This cycle of build, push, test, and rebuild ensures the image works in hybrid scenarios—where parts of the application may run on‑premises and parts in Azure.
Once validated, the image can be deployed to Azure App Service, Azure Kubernetes Service (AKS), or other Azure compute services. When you create the Azure resource, you select the image from your ACR and then configure environment settings. The deployment pulls the image from the registry and runs it, making the application accessible. By combining Dockerfile authoring, multi‑stage builds, ACR publishing, and validation, you create container images that are efficient, portable, and ready for hybrid infrastructure.
Eager to master hybrid server management? Discover how to administer Windows Server Hybrid Core Infrastructure on Azure, setting your path towards the Microsoft Certified: Azure Hybrid Infrastructure Administrator Associate certification!
Prepare and test your skills

Prepare and test your skills

A Dockerfile is a script of instructions that tells Docker how to build a Windows Server container image. The first directive chooses a base image, such as Windows Nano Server, and each directive adds a new layer to the image.
Multi-stage builds help keep the final image small by using a first stage to install build tools and compile code, and a second stage that copies only the compiled output into a fresh, smaller base image. This ensures the final image contains only what is needed to run the application, not the temporary tools used during compilation.
To publish to ACR, you first log in to Azure and to ACR using az login and az acr login -n your_registry_name. Then you use docker push to upload the image, for example docker push your_registry_name.azurecr.io/myapp:1.0.