Usa la transmisión de imágenes para reducir el tiempo de inicio del contenedor
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
En este documento, se describe cómo usar la transmisión de imágenes para extraer imágenes de contenedor en trabajos de contenedor de Batch.
La transmisión de imágenes permite que los trabajos por lotes se inicialicen sin esperar a que finalice la descarga de una imagen de contenedor, lo que proporciona los siguientes beneficios:
Menor latencia cuando se extraen imágenes grandes
Menor tiempo para comenzar la ejecución del trabajo
Si tus imágenes de contenedor están protegidas por los Controles del servicio de VPC, actualiza tu perímetro de servicio para incluir containerfilesystem.googleapis.com.
Limitaciones
La transmisión de imágenes por lotes tiene las siguientes limitaciones:
Batch solo admite la transmisión de imágenes para las imágenes de contenedor que se almacenan en Artifact Registry. Si actualmente usas Container Registry para administrar tus imágenes de contenedor, puedes hacer la transición a Artifact Registry.
Debes ejecutar las VMs de tu trabajo de Batch en la misma ubicación en la que almacenas tu imagen de contenedor en Artifact Registry.
No se admiten los contenedores que usan la versión 2 del manifiesto de imágenes de Docker, esquema 1.
No se admiten imágenes de contenedor con capas vacías o duplicadas.
Crea un trabajo que use la transmisión de imágenes
Para crear un trabajo de contenedor de Batch que use la transmisión de imágenes, haz lo siguiente:
Usa Google Cloud CLI o la API de REST para crear un trabajo de contenedor.
Para habilitar la transmisión de imágenes para un contenedor ejecutable, configura el campo enableImageStreaming en true y el campo imageUri en una imagen almacenada en una ubicación de Artifact Registry que contenga la ubicación de la VM del trabajo.
"container":{..."enableImageStreaming":true}
Por ejemplo, un trabajo que usa la transmisión de imágenes tendría un archivo de configuración JSON similar al siguiente:
LOCATION: Es la ubicación regional o multirregional del repositorio en el que se almacena la imagen, por ejemplo, us-east1 o us. La ubicación del contenedor debe ser la misma que la de las VMs del trabajo por lotes.
PROJECT-ID: Es el proyecto que contiene la imagen del contenedor. Si el ID de tu proyecto contiene dos puntos (:), consulta Proyectos con alcance de dominio.
REPOSITORY: Es el nombre del repositorio en el que se almacena la imagen.
IMAGE por el nombre de la imagen de contenedor
TAG: Es la etiqueta que se aplica a la imagen.
¿Qué sigue?
Si tienes problemas para crear o ejecutar un trabajo, consulta Solución de problemas.
[[["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-05 (UTC)"],[[["\u003cp\u003eImage streaming reduces latency and speeds up job execution by allowing Batch jobs to start without waiting for full container image downloads.\u003c/p\u003e\n"],["\u003cp\u003eImage streaming is only supported for container images stored in Artifact Registry, and the job's VMs must be in the same location as the image.\u003c/p\u003e\n"],["\u003cp\u003eTo enable image streaming, set the \u003ccode\u003eenableImageStreaming\u003c/code\u003e field to \u003ccode\u003etrue\u003c/code\u003e in the container runnable configuration and specify the Artifact Registry image URI.\u003c/p\u003e\n"],["\u003cp\u003eWhen using Image streaming, container runnables support only specific fields: \u003ccode\u003eimageUri\u003c/code\u003e, \u003ccode\u003ecommands\u003c/code\u003e, \u003ccode\u003eentrypoint\u003c/code\u003e, \u003ccode\u003evolumes\u003c/code\u003e, and \u003ccode\u003eenableImageStreaming\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe container image used for image streaming must not have any empty or duplicate layers and must be of docker manifest version 2, schema 2.\u003c/p\u003e\n"]]],[],null,["# Use Image streaming to reduce container startup time\n\nThis document describes how to use Image streaming to pull container images\ninto Batch container jobs.\n\nImage streaming enables Batch jobs to initialize without waiting\nfor a container image to finish downloading, which provides the following\nbenefits:\n\n- Reduced latency when pulling large images\n- Faster time to begin job execution\n\nBefore you begin\n----------------\n\n1. If you haven't used Batch before, review [Get started with Batch](/batch/docs/get-started) and enable Batch by completing the [prerequisites for projects and users](/batch/docs/get-started#prerequisites).\n2.\n\n To get the permissions that\n you need to create a job,\n\n ask your administrator to grant you the\n following IAM roles:\n\n - [Batch Job Editor](/iam/docs/roles-permissions/batch#batch.jobsEditor) (`roles/batch.jobsEditor`) on the project\n - [Service Account User](/iam/docs/roles-permissions/iam#iam.serviceAccountUser) (`roles/iam.serviceAccountUser`) on the [job's service account](/batch/docs/create-run-job-custom-service-account#create-job-service-account), which by default is the [default Compute Engine service account](/compute/docs/access/service-accounts#default_service_account)\n\n\n For more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\n\n You might also be able to get\n the required permissions through [custom\n roles](/iam/docs/creating-custom-roles) or other [predefined\n roles](/iam/docs/roles-overview#predefined).\n3. If you haven't already done so, enable the Container File System API by\n running the following command:\n\n ```\n gcloud services enable containerfilesystem.googleapis.com\n ```\n4. If your container images are protected by VPC Service Controls, [update your service perimeter](/vpc-service-controls/docs/manage-service-perimeters#update) to include `containerfilesystem.googleapis.com`.\n\n\u003cbr /\u003e\n\nLimitations\n-----------\n\nBatch Image streaming has the following limitations:\n\n- Batch only supports Image streaming for container images that are stored in Artifact Registry. If you currently use Container Registry to manage your container images, you can [transition to Artifact Registry](/artifact-registry/docs/transition/transition-from-gcr).\n- You must run your Batch job's VMs in the same [location](/artifact-registry/docs/repositories/repo-locations) as where you store your container image in Artifact Registry.\n- Containers that use the Docker image manifest version 2, schema 1 aren't supported.\n- When you use Image streaming, [containers runnables](/batch/docs/reference/rest/v1/projects.locations.jobs#container) only support the following fields:\n - `imageUri`\n - `commands`\n - `entrypoint`\n - `volumes`\n - `enableImageStreaming`\n- Container images with empty layers or duplicate layers aren't supported.\n\nCreate a job that uses Image streaming\n--------------------------------------\n\nCreate a Batch container job that uses Image streaming by doing\nthe following:\n\nUse the Google Cloud CLI or REST API to\n[create a container job](/batch/docs/create-run-basic-job#create-basic-container-job).\nTo enable Image streaming for a container runnable, set\n`enableImageStreaming` field to `true` and set the `imageUri` field to an image\nthat is stored in an\n[Artifact Registry location](/artifact-registry/docs/repositories/repo-locations)\nthat contains the location of the job's VM. \n\n \"container\": {\n ...\n \"enableImageStreaming\": true\n }\n\n| **Note:** When you use Image streaming, [containers runnables](/batch/docs/reference/rest/v1/projects.locations.jobs#container) only support the `imageUri`, `commands`, `entrypoint`, `volumes`, and `enableImageStreaming` fields.\n\nFor example, a job that uses Image streaming would have a JSON\nconfiguration file similar to the following: \n\n {\n \"taskGroups\": [\n {\n \"taskCount\": \"1\",\n \"taskCountPerNode\": \"1\",\n \"taskSpec\": {\n \"runnables\": [\n {\n \"container\": {\n \"imageUri\": \"\u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e-docker.pkg.dev/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/\u003cvar translate=\"no\"\u003eREPOSITORY\u003c/var\u003e/\u003cvar translate=\"no\"\u003eIMAGE\u003c/var\u003e:\u003cvar translate=\"no\"\u003eTAG\u003c/var\u003e\",\n \"enableImageStreaming\": true\n }\n }\n ]\n }\n }\n ],\n \"allocationPolicy\": {\n \"instances\": [\n {\n \"policy\": {\n \"machineType\": \"e2-standard-4\"\n }\n }\n ]\n },\n \"logsPolicy\": {\n \"destination\": \"CLOUD_LOGGING\"\n }\n }\n\nReplace the following values:\n\n- \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e: the regional or multi-regional [location](/artifact-registry/docs/repositories/repo-locations) of the repository where the image is stored, for example `us-east1` or `us`. The location of the container must be the same as the location of the Batch job's VMs.\n- \u003cvar translate=\"no\"\u003ePROJECT-ID\u003c/var\u003e: the project that contains the container image. If your project ID contains a colon (`:`), see [Domain-scoped projects](/artifact-registry/docs/docker/names#domain).\n- \u003cvar translate=\"no\"\u003eREPOSITORY\u003c/var\u003e: the name of the repository where the image is stored.\n- \u003cvar translate=\"no\"\u003eIMAGE\u003c/var\u003e: the name of the container image.\n- \u003cvar translate=\"no\"\u003eTAG\u003c/var\u003e: the tag applied to the image.\n\nWhat's next\n-----------\n\n- If you have issues creating or running a job, see [Troubleshooting](/batch/docs/troubleshooting).\n- [View jobs and tasks](/batch/docs/view-jobs-tasks).\n- Learn about more [job creation options](/batch/docs/create-run-job#job-creation-options)."]]