VM Templates and Machine Images


Introduction to Google Compute Engine

The course is part of this learning path

Start course

This course will introduce you to the Google Compute Engine. 

Learning Objectives

  • What Google Compute Engine is
  • How it differs from the other Google compute offerings
  • How to create virtual machine instances from scratch, from a template, and from a machine image

Intended Audience

  • Cloud Architects
  • System Administrators
  • GCP Developers
  • Anyone preparing for a Google Cloud certification


  • Basic understanding of Virtual Machines
  • Access to a GCP account



So, at this point, you should be able to create VMs manually. Now this is great if you only need to manage a handful. But what if you need to manage hundreds or even thousands of VMs?

Well, in that case, you're going to be very interested in what I present in this lesson. So, I'm going to show you how to use templates and disk images to create VMs. First, let's cover templates. Now to start, I'm going to choose create instance, and then I'll select from a template here on the left. Of course, this is going to require template, so let's go ahead and create one. Once you click on 'Create Instance Template', you're going to get a form that looks exactly like the one we saw before. Now this is because a VM template is basically a safe file for all your VM settings. So, make your selections and it's going to save them so you can use it later. Basically, if you need to make 100 instances of the same VM, you don't want to have to fill out the form 100 times. Instead, you can fill out the form once, save it to a template, and then use the template to create your instances.

So, I'm going to call my template demo-vm-template-1, and then I'll make a few selections and then click on 'Create'. Now remember this is not going to create a VM instance, this is going to create a template. So, now that the template has been created, I can create the instance. This is going to load in all the save settings from my template. And notice, I can still override any settings if I wish. But now, I can easily create the exact type of VM instance anytime I want. Let me specify a name for my new VM instance and then click on 'Create'. This is the part that will actually create a running VM. So, let me fast forward a little bit until it's complete, and there we go. That's how you create a VM using a template. Next, I want to show you how to create a VM using a machine image. Now, a machine image is similar to a VM template, but it takes things one step further. Not only does it let you re-create the same type of machine, but it also allows you to copy the exact discontents as well.

A machine image is basically a snapshot of one of your VM instances. And you can use that snapshot to create exact multiple copies of your VM. Now this is great because you can create a VM, spend a lot of time installing and configuring software and then you don't have to do the same thing for each new copy. You can figure one VM, create a image, and then use that image to create exact replicas. So, in order to demonstrate this, I'm actually first going to need to create a machine image. So, let me go back to my currently running VM instances and show you how to do that. Click on the more options menu and then select create new machine image. Now, I'm not going to go through all the options in detail here, these defaults work perfectly fine. I just need to give it a name and then click on 'Create'. And then I need to fast forward again. So, this is going to create a copy of my Debian Linux instance with Ops Agent installed. So, any new instance I create from this image is also going to have the Ops Agent automatically installed as well. Let me show you how to do that. I'll need to create a new instance and then I need to select create from machine image. And finally, I just need to select my image.

Now, once again, you can make any last-minute changes if you need. I just need to set a name for my new instance. And notice that the boot disk is different. It's not set to Debian Linux. Instead, it says it's going to come from a machine image. So, now I just have to scroll down and click on 'Create', and let me fast forward till it's done. So, now I have an exact copy of demo-vm1, and it's called demo-vm-from-image-1. You can use this technique to create as many copies of a VM as you wish. I just want to show you one last thing. It's very, very important. This is how you delete a VM instance. So, you pick the instance you want to delete, click on the 'More Actions' menu button, and then select delete. Now, that works if you want to delete instances one at a time. If you want to delete multiple instances all at the same time, you can do that as well. Just select all the instances you want to delete, click on the more actions button up here at the top, and then click on delete. I also am going to go ahead and delete my template and delete the machine image I made as well. As you can see, using templates and machine images can make creating VMs a whole lot easier.


About the Author
Learning Paths

Daniel began his career as a Software Engineer, focusing mostly on web and mobile development. After twenty years of dealing with insufficient training and fragmented documentation, he decided to use his extensive experience to help the next generation of engineers.

Daniel has spent his most recent years designing and running technical classes for both Amazon and Microsoft. Today at Cloud Academy, he is working on building out an extensive Google Cloud training library.

When he isn’t working or tinkering in his home lab, Daniel enjoys BBQing, target shooting, and watching classic movies.