Working with Custom Images on Google Compute Engine

1 hour
  • 5 Learning Objectives

About this Hands-on Lab

In this hands-on lab, we are going to practice creating custom images from 2 versions of a web server (which will be provided for you), add both images to the same image family, describe the image family, deprecate an image, and create a new web server from our custom images.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create image from base-apache instance using web console.

Create custom image from base-apache instance using web console:

  • Stop the instance
  • Go to Compute Engine > Images
  • Name image "webserver-base"
  • Set Family to "webserver"
  • In the Source dropdown menu, select Disk
  • In the Source disk dropdown menu, select base-apache
  • Click Create
Create image from custom-webpage instance using gcloud command.

Create image from custom-webpage instance using gcloud command:

  • Stop the instance
  • Open Cloud Shell
  • Enter command to create image from the custom-webpage disk, name the image "custom-webpage", and add to the webserver image family
    • gcloud compute images create custom-webpage --source-disk=custom-webpage --source-disk-zone=us-central1-a --family=webserver
  • Verify that image is created and in the appropriate family using the web console
View images in web console and view ‘webserver’ image family information in command line.

View images in web console and view webserver image family information in command line:

  • In web console, go to Compute Engine > Images
  • To describe image family and view latest image, enter command:
    • gcloud compute images describe-from-family webserver
  • Shown image is the latest version
Deprecate base image in our ‘webserver’ image family using command line.

Deprecate base version using command line:

  • First, view process in web console:
    • Go back to Compute Image > Images
    • Place check next to webserver-base, and click DEPRECATE from the three dot icons on the far right.
    • Set State to Deprecated, and set Replacement as custom-page-1
    • Cancel out and do the same thing via command line.
  • In Cloud Shell, enter:
    • gcloud compute images deprecate webserver-base --state DEPRECATED
  • Verify in web console
Create a new web server from custom image.

Create a new web server from custom image:

  • Go to Compute Engine > VM Instances
  • Click Create Instance
  • Place it in any region and zone you want
  • Name the instance "new-web-server"
  • Under Boot disk, click Change
  • Click on Custom images from the top menu
  • Click on Show deprecated images to view all images
  • Select custom-webpage, and click Select
  • Check the box for Allow HTTP traffic under Firewall settings
  • Click Create
  • Once the instance is up, click the external IP address to verify the new web page works

Additional Resources

Be sure to launch the lab in incognito (or other private view) mode to avoid cached login issues.

You will have two custom web servers created in Compute Engine for you when you begin the lab.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?