Configura la compilación y la ejecución de imágenes
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Buildpacks usa un compilador predeterminado que consiste en todos los componentes necesarios para ejecutar una compilación de tu servicio, incluidas una imagen de compilación y una imagen de ejecución:
Imagen de compilación: La usa la imagen del compilador para crear el entorno de compilación en el que se ejecuta el ciclo de vida de los paquetes de compilación. Aquí es donde se prepara tu aplicación o función para la contenedorización.
Imagen de ejecución: Es la imagen base a partir de la cual se compila la imagen del contenedor de tu servicio. Esta es la imagen que aloja la aplicación o función compilada.
Ambas imágenes se pueden personalizar y extender para adaptarse a tus necesidades. Por ejemplo, puedes personalizar las imágenes para agregar los paquetes necesarios para compilar el servicio o instalar paquetes del sistema para que estén disponibles cuando se ejecute el servicio.
Antes de comenzar
Usa la CLI de pack para compilar tu servicio de forma local en una imagen de contenedor.
Instala la herramienta de control de fuente Git para obtener la aplicación de ejemplo de GitHub.
Personaliza las imágenes de compilación y ejecución
Buildpacks usa una imagen de compilador para construir tu servicio en una imagen de contenedor. Cuando se completa el proceso de compilación, la aplicación o función se inserta en una imagen de ejecución. Obtén más información sobre el proceso de compilación en Conceptos de Paquetes de compilación.
Extiende la imagen de compilador
Para personalizar la imagen del compilador predeterminada, haz lo siguiente:
Crea un builder.Dockerfile personalizado a partir de la imagen de compilador predeterminada. Debes especificar la etiqueta para la versión del compilador que admita tu imagen base. Por ejemplo, la etiqueta de imagen base :v1 no es compatible con la etiqueta de compilador :google-22.
SERVICE_IMAGE_NAME por el nombre que elijas para la imagen de la función o aplicación.
BUILDER_IMAGE_NAME por el nombre de la imagen de compilador personalizada.
Extiende la imagen de ejecución
Para personalizar la imagen de contenedor de ejecución predeterminada, haz lo siguiente:
Crea un run.Dockerfile personalizado a partir de la imagen de ejecución predeterminada. Debes especificar la etiqueta de la versión del compilador que admita tu imagen de ejecución. Por ejemplo, la etiqueta de imagen de ejecución :v1 no es compatible con la etiqueta del compilador :google-22.
[[["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\u003eBuildpacks utilize a builder image, consisting of both a build image for creating the build environment and a run image that hosts the built application or function.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003epack\u003c/code\u003e CLI tool is used to build a service into a container image locally, requiring Docker, Pack CLI, and Git to be installed beforehand.\u003c/p\u003e\n"],["\u003cp\u003eBuilder images can be customized by creating a \u003ccode\u003ebuilder.Dockerfile\u003c/code\u003e and using \u003ccode\u003edocker build\u003c/code\u003e to add necessary packages or components to the building process, and then can be used via \u003ccode\u003epack build\u003c/code\u003e to build a service.\u003c/p\u003e\n"],["\u003cp\u003eRun images can also be customized by creating a \u003ccode\u003erun.Dockerfile\u003c/code\u003e, using \u003ccode\u003edocker build\u003c/code\u003e to add necessary system packages or components, and then using \u003ccode\u003epack build\u003c/code\u003e with the \u003ccode\u003e--run-image\u003c/code\u003e flag to build a service using the customized image.\u003c/p\u003e\n"]]],[],null,["# Configure your build and run images\n\nBuildpacks uses a default\n[builder](https://buildpacks.io/docs/for-platform-operators/concepts/builder/),\nwhich consists of all the components necessary to execute a build of your\nservice including both a *build* and *run* image:\n\n- **Build image** : Used by the builder image to create the build environment where the buildpacks [lifecycle](https://buildpacks.io/docs/for-platform-operators/concepts/lifecycle/) is executed. This is where your application or function is prepared for containerization.\n- **Run image**: The base image from which the container image of your service is built. This is the image that hosts your built application or function.\n\nBoth images can be customized and extended to suit your needs. For example, you\ncan customize images to add the packages that are required for building your\nservice, or to install system packages so they are available when your\nservice runs.\n\nBefore you begin\n----------------\n\nYou use the `pack` CLI to locally build your service into a container image.\n\n### Before you begin\n\n1. Install [Docker Community Edition (CE)](https://docs.docker.com/engine/installation/) on your workstation. Docker is used by `pack` as an OCI image builder.\n2. Install [Pack CLI](https://buildpacks.io/docs/tools/pack/).\n3. Install the [Git source control](https://git-scm.com/downloads) tool to fetch the sample application from GitHub.\n\nCustomize the build and run images\n----------------------------------\n\nBuildpacks use a builder image to construct your service into a\ncontainer image. When the build process is complete, your application or\nfunction is inserted into a run image. Learn more about the build process\nat [Buildpacks Concepts](https://buildpacks.io/docs/for-platform-operators/concepts/).\n\n### Extending the builder image\n\nTo customize the default builder image:\n\n1. Create a custom `builder.Dockerfile` from the default builder image. You\n must specify the tag for the\n [version of the builder](/docs/buildpacks/builders) that supports your base\n image. For example, the `:v1` base image tag is unsupported by the\n `:google-22` builder tag.\n\n Example: \n\n FROM gcr.io/buildpacks/builder\n USER root\n RUN apt-get update && apt-get install -y --no-install-recommends \\\n subversion && \\\n apt-get clean && \\\n rm -rf /var/lib/apt/lists/*\n USER cnb\n\n2. Build your custom builder image from the `builder.Dockerfile` file:\n\n docker build -t \u003cvar translate=\"no\"\u003eBUILDER_IMAGE_NAME\u003c/var\u003e -f builder.Dockerfile .\n\n Replace `BUILDER_IMAGE_NAME` with the name that you choose for your custom\n builder image.\n3. Run the [`pack build`\n command](https://buildpacks.io/docs/tools/pack/cli/pack_build/)\n with your custom builder image to build the new container image of your\n application or function:\n\n pack build \u003cvar translate=\"no\"\u003eSERVICE_IMAGE_NAME\u003c/var\u003e --builder \u003cvar translate=\"no\"\u003eBUILDER_IMAGE_NAME\u003c/var\u003e\n\n Replace:\n - `SERVICE_IMAGE_NAME` with the name that you choose for your application or function image.\n - `BUILDER_IMAGE_NAME` with the name of your custom builder image.\n\n### Extending the run image\n\nTo customize the default run container image:\n\n1. Create a custom `run.Dockerfile` from the default run image. You\n must specify the tag for the\n [version of the builder](/docs/buildpacks/builders) that supports your run\n image. For example, the `:v1` run image tag is unsupported by the\n `:google-22` builder tag.\n\n Example: \n\n FROM gcr.io/buildpacks/gcp/run\n USER root\n RUN apt-get update && apt-get install -y --no-install-recommends \\\n imagemagick && \\\n apt-get clean && \\\n rm -rf /var/lib/apt/lists/*\n USER 33:33\n\n2. Build your custom run image from the `run.Dockerfile` file:\n\n docker build -t \u003cvar translate=\"no\"\u003eRUN_IMAGE_NAME\u003c/var\u003e -f run.Dockerfile .\n\n Replace `RUN_IMAGE_NAME` with the name that you choose for your custom run\n image.\n3. Run the [`pack build`\n command](https://buildpacks.io/docs/tools/pack/cli/pack_build/)\n with your custom run image to build the new container image of your\n application or function:\n\n pack build \u003cvar translate=\"no\"\u003eSERVICE_IMAGE_NAME\u003c/var\u003e --builder gcr.io/buildpacks/builder:v1 --run-image \u003cvar translate=\"no\"\u003eRUN_IMAGE\u003c/var\u003e\n\n Replace:\n - `SERVICE_IMAGE_NAME` with the name that you choose for your application or function image.\n - `RUN_IMAGE_NAME` with the name of your custom run image."]]