Lab setup instructions and requirements
Protect your account and progress. Always use a private browser window and lab credentials to run this lab.

Containerize a Windows Application

Lab 1 hour universal_currency_alt 5 Credits show_chart Intermediate
info This lab may incorporate AI tools to support your learning.
This content is not yet optimized for mobile devices.
For the best experience, please visit us on a desktop computer using a link sent by email.

Overview

In this lab, you deploy a simple Windows app to Docker running on a Compute Engine instance. You will then push the same app into Google Container Registry and deploy it to Google Kubernetes Engine.

Objectives

In this lab, you learn how to perform the following tasks:

  • Create a simple Windows app.
  • Containerize the app using Docker.
  • Create your Kubernetes cluster on Kubernetes Engine.
  • Deploy your app to a pod.
  • Allow external traffic to your pod.

Setup and requirements

For each lab, you get a new Google Cloud project and set of resources for a fixed time at no cost.

  1. Sign in to Google Skills using an incognito window.

  2. Note the lab's access time (for example, 1:15:00), and make sure you can finish within that time. There is no pause feature. You can restart if needed, but you have to start at the beginning.

  3. When ready, click Start lab.

  4. Note your lab credentials (Username and Password). You will use them to sign in to the Google Cloud Console.

  5. Click Open Google Console.

  6. Click Use another account and copy/paste credentials for this lab into the prompts. If you use other credentials, you'll receive errors or incur charges.

  7. Accept the terms and skip the recovery resource page.

Task 1. Enable Google Container Registry API

  1. On the Google Cloud menu, click Activate Cloud Shell (Activate Cloud Shell icon) icon then click Continue.

  2. Make sure the Google Container Registry API is enabled, by running the following command:

gcloud services enable containerregistry.googleapis.com

Task 2. RDP into the Windows VM

  1. On the Navigation menu (Navigation menu), click Compute Engine > VM instances.

  2. Click the Drop down arrow icon next to RDP button and select Set Windows password.

  3. Copy and save the Username value and click SET.

  4. Copy and save the New Windows Password and click CLOSE.

  5. Log into the Windows VM by clicking the RDP button of the VM:

instance_rdp.png

  1. Use credentials created in previous steps.

Once inside the Windows VM, you'll notice that it's a bare-minimum OS with minimal UI.

Note: If the command line window is not open, open it by going to Task Manager:
Ctrl + Alt + Delete and choose "Task Manager".
Then, go to File > Run new task > cmd.

In the Windows command prompt (C:\Users\gcpstagingXXXXX_stud>), run the following to see the images that are installed by default:

docker images

Output:

REPOSITORY TAG IMAGE ID mcr.microsoft.com/windows/servercore ltsc2019 29a2c2cb7e4d

Task 3. Create a Windows container app

For the app inside the Windows container, use an IIS Web Server. IIS has an image for Windows Server 2019. You can use the image as is and it will serve the default IIS page, but fot this lab, do something more interesting and have IIS serve a page you define.

  1. Create a folder called my-windows-app and enter into the directory:
mkdir my-windows-app cd my-windows-app
  1. Create folder named content:
mkdir content
  1. Create a file named index.html in the content folder:
call > content\index.html
  1. Edit index.html:
notepad content\index.html
  1. Add the following content to index.html:
<html> <head> <title>Windows containers</title> </head> <body> <p>Windows containers are cool!</p> </body> </html>
  1. Save the index.html. This is the page IIS will serve.

Task 4. Build Docker image

  1. Create a Dockerfile for the Docker image:
call > Dockerfile
  1. Edit the dockerfile:
notepad Dockerfile
  1. Add the following contents in the Dockerfile:
FROM mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2019 RUN powershell -NoProfile -Command Remove-Item -Recurse C:\inetpub\wwwroot\* WORKDIR /inetpub/wwwroot COPY content/ .
  1. Save the Dockerfile.

  2. Build the Docker image and tag it with Google Container Registry (GCR) and your project id. This will be useful when we push the image to GCR later (replace [PROJECT_ID] with your Google Skills project id):

docker build -t gcr.io/[PROJECT_ID]/iis-site-windows .
  1. Once the Docker image is built, you can see it along with its IIS dependency:
docker images

Sample output:

REPOSITORY TAG gcr.io/[PROJECT_ID]/iis-site-windows latest mcr.microsoft.com/windows/servercore/iis windowsservercore-ltsc2019 mcr.microsoft.com/windows/servercore ltsc2019
  1. Run the following command to run the Windows container from your VM instance:
docker run -d -p 80:80 gcr.io/[PROJECT_ID]/iis-site-windows
  1. Return to the Cloud Console. On the Navigation menu (Navigation menu icon), click Compute Engine > VM instances.

  2. Open a browser window enter the External IP of the Compute Engine instance to see the app:

The app displaying the following message: Windows containers are cool!

Click Check my progress below to verify you're on track in this lab.

Build Docker image

Task 5. Push container image to Google Container Registry

  1. Configure Docker to point to Google Container Registry (GCR):
gcloud auth configure-docker
  1. When prompted enter Y.

The output should look like this:

Adding credentials for all GCR repositories. WARNING: A long list of credential helpers may cause delays running 'docker build'. We recommend passing the registry name to configure only the registry you are using. After update, the following will be written to your Docker config file located at [C:\Users\student_01_9786da300\.docker\config.json]: { "credHelpers": { "gcr.io": "gcloud", "us.gcr.io": "gcloud", "eu.gcr.io": "gcloud", "asia.gcr.io": "gcloud", "staging-k8s.gcr.io": "gcloud", "marketplace.gcr.io": "gcloud" } } Do you want to continue (Y/n)? Y Docker configuration file updated.
  1. Push the image to Google Container Repository. Remember to replace [PROJECT_ID] with your Google Skills project id:
docker push gcr.io/[PROJECT_ID]/iis-site-windows
  1. If you return to the Cloud Console and go Google Container Repository in the Navigation Menu you can see the image.

The image listed on the Repositories page

Task 6. Start a Kubernetes Engine cluster

  1. On the Google Cloud menu, click Activate Cloud Shell (Activate Cloud Shell icon) icon then click Continue.

  2. Run the following command to set your environment variables for the project and zones and to set them as default:

export PROJECT_ID=[PROJECT_ID] gcloud config set project ${PROJECT_ID} export ZONE=us-central1-a gcloud config set compute/zone ${ZONE}
  1. Start a Kubernetes cluster managed by Kubernetes Engine. Name the cluster win-cluster and configure it to run 2 nodes:
export CLUSTER_NAME=win-cluster export CLUSTER_VERSION=1.24.3-gke.200 gcloud container clusters create ${CLUSTER_NAME} \ --enable-ip-alias \ --num-nodes=2 \ --cluster-version=${CLUSTER_VERSION}

It takes several minutes to create a cluster as Kubernetes Engine provisions virtual machines for you. Eventually, the cluster should be created.

Example output:

Creating cluster my-win-cluster in us-central1-a...done. Created [https://container.googleapis.com/v1/projects/qwiklabs-gcp-03-3de91b1579f6/zones/us-central1-a/clusters/my-win-cluster]. To inspect the contents of your cluster, go to: https://console.cloud.google.com/kubernetes/workload_/gcloud/us-central1-a/my-win-cluster?project=qwiklabs-gcp-03-3de91b1579f6 kubeconfig entry generated for my-win-cluster. NAME LOCATION MASTER_VERSION MASTER_IP MACHINE_TYPE NODE_VERSION NUM_NODES STATUS my-win-cluster us-central1-a 1.24.3-gke.200 34.71.161.61 e2-medium 1.20.9-gke.1001 2 RUNNING Note: Alternatively, you could create this cluster via the Console: Kubernetes Engine > Clusters > Create cluster. Note: You can create the cluster in another zone, but we recommend that you keep it in the same region as the storage bucket used by the container registry (see previous step).
  1. After the cluster is created, check your installed version of Kubernetes using the kubectl version command:
kubectl version

The gcloud container clusters create command automatically authenticated kubectl for you.

  1. View your running nodes in the Cloud Console. On the Navigation menu (Navigation menu icon), click Compute Engine > VM Instances.

    Your Kubernetes cluster is now ready for use.

Click Check my progress to verify the objective. Start a Kubernetes Engine cluster

Task 7. Add Windows Node to cluster

  • Once we have the basic GKE cluster, we can go ahead and add a Windows pool for Windows nodes to it:
gcloud container node-pools create windows-node-pool \ --cluster=${CLUSTER_NAME} \ --image-type=WINDOWS_LTSC_CONTAINERD \ --no-enable-autoupgrade \ --machine-type=n1-standard-2 Note: Notice that we're disabling automatic node upgrades. Windows container versions need to be compatible with the node OS version. To avoid unexpected workload disruption, it is recommended that users disable node autoupgrade for Windows node pools.

For Windows Server containers in GKE, you're already licensed for underlying Windows host VMs – containers need no additional licensing.

In the end, the GKE cluster is ready with 2 Linux nodes and 3 Windows nodes.

Task 8. Verify cluster initialization

Before running our Windows container as a pod on GKE, make sure the cluster is initialized.

  1. In Cloud Shell run the following command:
gcloud container clusters get-credentials ${CLUSTER_NAME}

kubectl is now setup to manage our cluster.

  1. Before using the cluster, wait for several seconds until windows.config.common-webhooks.networking.gke.io is created. This webhook adds scheduling tolerations to Pods created with the kubernetes.io/os: windows (or beta.kubernetes.io/os: windows) node selector to ensure they are allowed to run on Windows Server nodes. It also validates the Pod to ensure that it only uses features supported on Windows.
kubectl get mutatingwebhookconfigurations

Output:

NAME CREATED AT windows.config.common-webhooks.networking.gke.io 2020-01-20T15:09:16Z ... Now the cluster is ready for Windows containers.

Click Check my progress below to verify you're on track in this lab.

Deploy a Windows node pool

Task 9. Run Windows container as a pod in GKE

  1. Create and open a file called iis-site-windows.yaml with nano using the following command:
nano iis-site-windows.yaml
  1. Once nano has opened, paste following into the file (Remember to replace [PROJECT_ID] with your Google Skills project id):
apiVersion: apps/v1 kind: Deployment metadata: name: iis-site-windows labels: app: iis-site-windows spec: replicas: 2 selector: matchLabels: app: iis-site-windows template: metadata: labels: app: iis-site-windows spec: nodeSelector: kubernetes.io/os: windows containers: - name: iis-site-windows image: gcr.io/[PROJECT_ID]/iis-site-windows ports: - containerPort: 80
  1. Press Ctrl+O, and then press Enter to save your edited file.

  2. Press Ctrl+X to exit the nano text editor.

  3. Create a deployment for the cluster with the following command:

kubectl apply -f iis-site-windows.yaml
  1. Check the deployment with the following command:
kubectl get deployment,pods

After a few minutes, you should see the deployment created and pods running:

NAME READY UP-TO-DATE AVAILABLE AGE deployment.extensions/iis-site-windows 2/2 2 2 3m4s NAME READY STATUS RESTARTS AGE pod/iis-site-windows-5b6dfdf64b-k5b6r 1/1 Running 0 3m4s pod/iis-site-windows-5b6dfdf64b-msr9s 1/1 Running 0

Task 10. Create a Kubernetes service

  1. To make pods accessible to the outside world, we need to create a Kubernetes service with LoadBalancer type:
kubectl expose deployment iis-site-windows --type="LoadBalancer"

In a few minutes, you should see a new service with an external IP:

kubectl get service

You should see an output like this:

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) iis-site-windows LoadBalancer 10.107.11.34 104.155.45.254 80:30035/TCP
  1. Open a browser window and go to the external IP of the load balancer, you will see the app:

The app displayinng the following message: Windows containers are cool!

Deploy a LoadBalancer

Congratulations!

You have successfully configured and deployed a GKE cluster running a Windows Server workload.

In this lab, you learned how to perform the following tasks:

  • Create a simple Windows app.
  • Containerize the app using Docker.
  • Create your Kubernetes cluster on Kubernetes Engine.
  • Deploy your app to a pod.
  • Allow external traffic to your pod.

Copyright 2026 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.

Before you begin

  1. Labs create a Google Cloud project and resources for a fixed time
  2. Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
  3. On the top left of your screen, click Start lab to begin

Use private browsing

  1. Copy the provided Username and Password for the lab
  2. Click Open console in private mode

Sign in to the Console

  1. Sign in using your lab credentials. Using other credentials might cause errors or incur charges.
  2. Accept the terms, and skip the recovery resource page
  3. Don't click End lab unless you've finished the lab or want to restart it, as it will clear your work and remove the project

This content is not currently available

We will notify you via email when it becomes available

Great!

We will contact you via email if it becomes available

One lab at a time

Confirm to end all existing labs and start this one

Use private browsing to run the lab

Using an Incognito or private browser window is the best way to run this lab. This prevents any conflicts between your personal account and the Student account, which may cause extra charges incurred to your personal account.