Google Cloud cheatsheet: share VM images

Xianbo QIAN
Google Cloud - Community
1 min readMay 23, 2018

Sharing VM images is an easy way to spawn large number of instances with the same environment. What’s more interesting is that these VM images could be shared across projects. Let’s say that image is created in project SRC and will be used by project DEST. Here is a list of things that you should do:

  • Create an image from an instance or clone it from another image
gcloud compute images create [IMAGE_NAME] \
--source-image [SOURCE_IMAGE] \
--source-image-project [IMAGE_PROJECT_SRC] \
--family [IMAGE_FAMILY] \
--project [IMAGE_PROJECT_DEST]
  • List available images in the project and make sure that image you picked actually exists
gcloud compute images list --project [IMAGE_PROJECT_SRC]
  • Create image in project DEST
gcloud compute instances create [INSTANCE_NAME]
--image-family [IMAGE_FAMILY]
--image-project [IMAGE_PROJECT_SRC]
--project [IMAGE_PROJECT_DEST]

--

--