Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Per eseguire il deployment in Cloud Run, devi fornire un'immagine container.
Un'immagine container è un formato di pacchetti che include il codice, i relativi pacchetti, eventuali dipendenze binarie necessarie, il sistema operativo da utilizzare e tutto ciò che è necessario per eseguire il servizio.
Dockerfile
Un file denominato Dockerfile viene spesso utilizzato per dichiarare come creare l'immagine container. Puoi trovare esempi di Dockerfile per i linguaggi più diffusi nella guida rapida alla creazione e al deployment.
I file Docker iniziano molto spesso da un'immagine di base (ad es. FROM golang:1.11). Puoi trovare le immagini di base gestite dagli autori del sistema operativo e del linguaggio su Docker Hub.
Cloud Build controlla la presenza di immagini memorizzate nella cache
prima di eseguire il pull da Docker Hub. Se utilizzi uno strumento di compilazione di terze parti, puoi configurare il tuo daemon Docker in modo che controlli la presenza di immagini nella stessa cache. Puoi anche trovare le immagini di base gestite da Google in Google Cloud Marketplace.
Se fornisci i tuoi binari, assicurati che siano compilati per l'ABI Linux x86_64.
Queste risorse forniscono ulteriori informazioni sui file Dockerfile:
I buildpack di Google Cloud ti aiutano a compilare il codice sorgente da un insieme di linguaggi supportati in immagini container senza bisogno di un Dockerfile.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[],[],null,["# Containerize your code\n\nTo deploy to Cloud Run, you need to provide a *container image*.\nA container image is a packaging format that includes your code, its\npackages, any needed binary dependencies, the operating system to use, and\nanything else needed to run your service.\n\nDockerfile\n----------\n\nA file named [Dockerfile](https://docs.docker.com/engine/reference/builder/) is\ncommonly used to declare how to build the container image. You can find examples\nof Dockerfiles for popular languages in the\n[build and deploy quickstart](/run/docs/quickstarts#build-and-deploy-a-web-service).\n\nDockerfiles very often start from a base image (e.g. `FROM golang:1.11`).\nYou can find base images maintained by OS and language authors on\n[Docker Hub](https://hub.docker.com/).\nCloud Build checks for [cached images](/container-registry/docs/pulling-cached-images)\nbefore pulling from Docker Hub. If you use a third-party build tool, you can\nconfigure your Docker daemon to check for images in the same cache. You can also\nfind base images managed by Google in the\n[Google Cloud Marketplace](https://console.cloud.google.com/marketplace/browse?filter=solution-type:container&filter=category:os).\n| **Note:** As of November 1, 2020, Docker Hub\n| [rate limits](https://www.docker.com/blog/scaling-docker-to-serve-millions-more-developers-network-egress/) apply to unauthenticated or authenticated pull requests on the\n| Docker Free plan. To avoid disruptions and have greater control over your\n| software supply chain, you can migrate your dependencies to [Artifact Registry](/artifact-registry/docs/docker/migrate-external-containers).\n\nIf you bring your own binaries, make sure they are compiled for Linux ABI\nx86_64.\n\nThese resources provide further information on Dockerfiles:\n\n- Learn Dockerfile syntax through the [Dockerfile reference](https://docs.docker.com/engine/reference/builder).\n- Learn how Dockerfiles fit together through the tips in [Best practices for writing Dockerfiles](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/).\n\nBuildpacks\n----------\n\n[Google Cloud's buildpacks](/docs/buildpacks/builders) helps you build source code\nfrom a set of supported languages into container images without the need for a\nDockerfile.\n\nWhat's next\n-----------\n\nAfter you have containerized your code,\n[build a container image](/run/docs/building/containers) then continue iterating\nin [local testing](/run/docs/testing/local)."]]