Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Usa una imagen de máquina para almacenar la configuración, los metadatos, los permisos y los datos de varios discos para una instancia de VM que se ejecuta en Compute Engine. La instancia de VM que usas para crear una imagen de máquina se denomina instancia de origen.
Para obtener información sobre cuándo y cómo usar las imágenes de máquina, consulta Imágenes de máquina.
En este documento, se describen los pasos para crear una imagen de máquina a partir de una instancia de origen.
Antes de empezar
Si aún no lo hiciste, configura la autenticación.
La autenticación verifica tu identidad para acceder a los Google Cloud servicios y las APIs. Para ejecutar código o muestras desde un entorno de desarrollo local, puedes autenticarte en Compute Engine seleccionando una de las siguientes opciones:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and
APIs, you don't need to set up authentication.
gcloud
Instala Google Cloud CLI.
Después de la instalación,
inicializa Google Cloud CLI ejecutando el siguiente comando:
Si usas una CSEK para proteger tu imagen de máquina, se almacenará una copia completa de todos los datos del disco durante la generación de la imagen de máquina. En todas las demás situaciones, los datos del disco se almacenan en las copias diferenciales.
No puedes crear imágenes de máquina a partir de VMs de origen que:
Tengan más de 200 TB de discos conectados
No tengan ningún disco conectado
Tengan volúmenes de Hyperdisk conectados
Usa el tipo de máquina Z3, excepto z3-highmem-192-highlssd-metal.
Usa un tipo de máquina C3D, H3 o A3.
En el caso de las instancias que no admiten la creación de imágenes de máquina, puedes crear una imagen de SO a partir del disco de arranque de la instancia, como se describe en Crea imágenes personalizadas.
Las propiedades de instancias y discos no son compatibles con la imagen de máquina
Cuando creas imágenes de máquina a partir de instancias de VM o instancias de VM a partir de imágenes de máquina, las siguientes propiedades de instancia y el disco no se conservan ni se restablecen:
disks.architecture
disks.description
disks.labels
disks.locked
disks.multiWriter
disks.onUpdateAction
disks.provisionedIops
disks.shieldedInstanceInitialState
disks.sourceImage
disks.sourceImageEncryptionKey
disks.sourceInstantSnapshot
disks.sourceSnapshot
disks.sourceSnapshotEncryptionKey
privateIpv6GoogleAccess
resourceManagerTags
resourcePolicies
secure_tag
shieldedInstanceConfig
Crea una imagen de máquina a partir de una VM
Permisos necesarios para esta tarea
Para hacer esta tarea, debes tener los siguientes permisos:
compute.machineImages.create en el proyecto
compute.instances.useReadOnly en la instancia de origen
Una clave de encriptación opcional. Puedes elegir entre una clave Google-owned and Google-managed encryption key, una clave de Cloud Key Management Service (Cloud KMS) o una clave de encriptación proporcionada por el cliente (CSEK). Si no se especifica una clave de encriptación, las imágenes de máquina se encriptarán con una Google-owned and Google-managed encryption key.
Si deseas usar una imagen de máquina para crear instantáneas de instancias y clonarlas, quita la información del SO y de la app que sea exclusiva antes de generar la imagen de máquina a partir de una instancia. Por ejemplo, en instancias de VM de Windows, usa GCESysprep a fin de preparar el sistema para la replicación.
Console
En la consola de Google Cloud , ve a la página Imágenes de máquina.
Especifica la ubicación en la que se almacenará la imagen de máquina (opcional). Elige entre almacenamiento multirregional o regional. Para obtener más información sobre la ubicación, consulta Ubicación de almacenamiento de imágenes de máquina.
MACHINE_IMAGE_NAME: Es el nombre de la imagen de máquina que deseas crear.
SOURCE_VM_NAME: Es el nombre de la instancia de VM de origen desde la que deseas crear la imagen.
Ejemplo
Por ejemplo, puedes usar el siguiente comando de gcloud para crear una imagen de máquina llamada my-machine-image desde una instancia de origen llamada my-instance:
MACHINE_IMAGE_NAME: Es el nombre de la imagen de máquina que deseas crear.
SOURCE_INSTANCE_URL: Es la URL parcial o completa de la instancia de origen que deseas usar para crear la imagen de máquina.
Por ejemplo, si tienes una instancia de origen llamada my-instance en un proyecto llamado myProject, las siguientes URL son válidas:
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-09-04 (UTC)"],[[["\u003cp\u003eMachine images store a VM instance's configuration, metadata, permissions, and data from multiple disks, using a source VM instance as the base.\u003c/p\u003e\n"],["\u003cp\u003eMachine images can be created through the Google Cloud console, the Google Cloud CLI, or REST API, requiring specific permissions such as \u003ccode\u003ecompute.machineImages.create\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eCreating a machine image involves specifying a name, the source VM instance, and its zone, with optional settings like storage location and encryption key, with a limit of six creations per instance every 60 minutes.\u003c/p\u003e\n"],["\u003cp\u003eCertain instance and disk properties are not preserved or restored when creating or using machine images, such as \u003ccode\u003edisks.architecture\u003c/code\u003e, \u003ccode\u003edisks.description\u003c/code\u003e, and \u003ccode\u003eresourcePolicies\u003c/code\u003e, among others.\u003c/p\u003e\n"],["\u003cp\u003eMachine images can not be created from source VMs that exceed 200TB of disks, have no attached disks, any attached Hyperdisk volumes or use a C3D, H3, A3 or Z3 machine type.\u003c/p\u003e\n"]]],[],null,["# Create machine images\n\n*** ** * ** ***\n\nUse a machine image to store all the\nconfiguration, metadata, permissions, and data from multiple disks for a VM\ninstance running on Compute Engine. The VM instance that you use to create a\nmachine image is referred to as a *source VM instance*.\n\nFor information about when and how to use machine images,\nsee [Machine images](/compute/docs/machine-images).\n\nThis document describes the steps for creating a machine image from a source VM\ninstance.\n\nBefore you begin\n----------------\n\n- If you haven't already, set up [authentication](/compute/docs/authentication). Authentication verifies your identity for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine by selecting one of the following options:\n\n Select the tab for how you plan to use the samples on this page: \n\n ### Console\n\n\n When you use the Google Cloud console to access Google Cloud services and\n APIs, you don't need to set up authentication.\n\n ### gcloud\n\n 1.\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n After installation,\n [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command:\n\n ```bash\n gcloud init\n ```\n\n\n If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n | **Note:** If you installed the gcloud CLI previously, make sure you have the latest version by running `gcloud components update`.\n 2. [Set a default region and zone](/compute/docs/gcloud-compute#set_default_zone_and_region_in_your_local_client).\n\n ### REST\n\n\n To use the REST API samples on this page in a local development environment, you use the\n credentials you provide to the gcloud CLI.\n 1. [Install](/sdk/docs/install) the Google Cloud CLI. After installation, [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command: \n\n ```bash\n gcloud init\n ```\n 2. If you're using an external identity provider (IdP), you must first [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n\n For more information, see\n [Authenticate for using REST](/docs/authentication/rest)\n in the Google Cloud authentication documentation.\n\nLimitations and restrictions\n----------------------------\n\n- You can create a machine image of a specific instance at most 6 times every 60 minutes.\n- You can protect a machine image by using either [Cloud Key Management Service (Cloud KMS)](/kms/docs) or a [customer-supplied encryption key (CSEK)](/compute/docs/disks/customer-supplied-encryption). The encryption key protects the content of the disks. However, metadata isn't protected.\n- If you use a CSEK to protect your machine image, a full copy of all disk data is stored during the generation of the machine image. In all other scenarios disk data is stored in [differential copies](/compute/docs/machine-images#disk-backup).\n- You can't create machine images from source VMs that:\n\n - Have greater than 200 TB of disks attached.\n - Don't have any attached disks.\n - Have any attached Hyperdisk volumes.\n - Use Z3 machine type except for `z3-highmem-192-highlssd-metal`.\n - Use a C3D, H3, or A3 machine type.\n\n For instances that don't support the creation of machine images, you can\n instead create an OS image from the boot disk of the instance, as described in\n [Create custom images](/compute/docs/images/create-custom).\n\n### Instance and disk properties not supported by machine image\n\nWhen you create machine images from VM instances or create VM instances from\nmachine images, the following instance and disk properties are not preserved\nor restored:\n\n- `disks.architecture`\n- `disks.description`\n- `disks.labels`\n- `disks.locked`\n- `disks.multiWriter`\n- `disks.onUpdateAction`\n- `disks.provisionedIops`\n- `disks.shieldedInstanceInitialState`\n- `disks.sourceImage`\n- `disks.sourceImageEncryptionKey`\n- `disks.sourceInstantSnapshot`\n- `disks.sourceSnapshot`\n- `disks.sourceSnapshotEncryptionKey`\n- `privateIpv6GoogleAccess`\n- `resourceManagerTags`\n- `resourcePolicies`\n- `secure_tag`\n- `shieldedInstanceConfig`\n\nCreating a machine image from a VM\n----------------------------------\n\n#### Permissions required for this task\n\nTo perform this task, you must have the following\n[permissions](/iam/docs/overview#permissions):\n\n\n- `compute.machineImages.create` on the project\n- `compute.instances.useReadOnly` on the source instance\n- `compute.disks.createSnapshot` on the disk\n\nYou can create machine images using either the\n[Google Cloud console](https://console.cloud.google.com/), the\n[Google Cloud CLI](/compute/docs/gcloud-compute), or\n[REST](/compute/docs/reference/rest/v1).\n\nTo create a machine image, you need the following information:\n\n- A name for the machine image that you want to create.\n- The name of the source VM instance.\n- The zone that the source VM instance is located in.\n- An optional description.\n- An optional [`storageLocation`](/compute/docs/machine-images#storage-location). If you don't specify a location, the default storage location is the [multiregional Cloud Storage location](/storage/docs/locations#location-mr) of the source VM instance.\n- An optional encryption key. You can choose between a Google-owned and Google-managed encryption key, a [Cloud Key Management Service (Cloud KMS)](/kms/docs) key or a [customer-supplied encryption (CSEK)](/compute/docs/disks/customer-supplied-encryption) key. If no encryption key is specified, machine images are encrypted using a Google-owned and Google-managed encryption key.\n- If you want to use a machine image for\n [instance cloning and snapshotting](/compute/docs/machine-images#cloning),\n remove the OS and app information that is unique to the instance before\n generating the machine image from an instance. For example, for Windows VM\n instances, use `GCESysprep` to prepare the system for replication.\n\n### Console\n\n1. In the Google Cloud console, go to the **Machine images** page.\n\n [Go to Machine images](https://console.cloud.google.com/compute/machineImages)\n2. Click **Create Machine image**.\n\n3. Specify a **Name** for your machine image.\n\n4. Optional: Provide a **Description**.\n\n5. Select the **Source VM instance**.\n\n6. Optional: Specify where to store the machine image. Choose between **Multi-regional**\n or **Regional** storage. For more information about location, see\n [Machine image storage location](/compute/docs/machine-images#storage-location).\n\n7. Optional: Select an **Encryption** method.\n\n8. Click **Create**.\n\n### gcloud\n\nUse the\n[`gcloud compute machine-images create`](/sdk/gcloud/reference/compute/machine-images/create)\ncommand to create a machine image from an instance. \n\n```\ngcloud compute machine-images create MACHINE_IMAGE_NAME \\\n --source-instance=SOURCE_VM_NAME\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eMACHINE_IMAGE_NAME\u003c/var\u003e: name of the machine image that you want to create.\n- \u003cvar translate=\"no\"\u003eSOURCE_VM_NAME\u003c/var\u003e: name of the source VM instance that you want to create the image from.\n\n**Example**\n\nFor example, you can use the following `gcloud` command to create a machine\nimage called `my-machine-image` from a source instance called `my-instance`: \n\n```\ngcloud compute machine-images create my-machine-image \\\n --source-instance=my-instance\n```\n\nThe process takes a few minutes. When the machine image is created, you get\nan output that resembles the following: \n\n```\nCreated [https://www.googleapis.com/compute/v1/projects/project-12345/global/machineImages/my-machine-image].\nNAME STATUS\nmy-machine-image READY\n```\n\n### REST\n\nIn the API, construct a `POST` request to the\n[`machineimages.insert`](/compute/docs/reference/rest/v1/machineImages/insert)\nmethod. In the request body, include the following `POST` request: \n\n```\nPOST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/machineImages\n\n{\n \"name\": \"MACHINE_IMAGE_NAME\",\n \"sourceInstance\": \"SOURCE_INSTANCE_URL\"\n}\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: [project ID](/resource-manager/docs/creating-managing-projects#identifying_projects).\n- \u003cvar translate=\"no\"\u003eMACHINE_IMAGE_NAME\u003c/var\u003e: name of the machine image that you want to create.\n- \u003cvar translate=\"no\"\u003eSOURCE_INSTANCE_URL\u003c/var\u003e: full or partial URL of\n the source VM instance that you want to use to create the machine image.\n For example, if you have a source instance called `my-instance` in\n a project called `myProject`. The following URLs are valid:\n\n - `https://www.googleapis.com/compute/v1/projects/myProject/global/instances/my-instance`\n - `projects/myProject/global/instances/my-instance`\n - `global/instances/my-instance`\n\nWhat's next?\n------------\n\n- Learn more about [machine images](/compute/docs/machine-images)\n- [Create VM instances from machine images](/compute/docs/machine-images/create-instance-from-machine-image)"]]