Container Registry is deprecated. Effective March 18, 2025, Container Registry is shut down and writing images to Container Registry is unavailable. For more information about the Container Registry deprecation and how to migrate to Artifact Registry, see Container Registry deprecation.
Stay organized with collections
Save and categorize content based on your preferences.
This page provides information about best practices for building and running
container images.
Building containers
The approach that you take to building container images can impact the
speed of builds and deployments, as well as the effort required to maintain
your images.
When you use images from public sources such as Docker Hub, you are
introducing code that your organization does not control into your software
supply chain. To mitigate risk, you can:
Build your own images to control image content.
Use a standardized base image and build on top of that image.
Scan images for vulnerabilities and address identified vulnerabilities.
Enforce standards and policies on images you deploy.
Making your registries public
You can make the registry in your Google Cloud project public by granting
read access on the registry storage bucket to the allUsers identity.
If all your users have Google Cloud accounts, you can limit access
to authenticated users with the allAuthenticatedUsers identity instead.
Consider the following guidelines before making a registry public:
Verify that all images you store in the registry are
sharable publicly and do not expose credentials, personal data, or
confidential data.
You are charged for network egress when users pull images.
If you expect a lot of internet download traffic, consider the associated
costs.
By default, projects have unlimited per-user quota.
To prevent abuse, cap per-user quotas within
your project.
Removing unused images
Remove unused container images to reduce storage costs and mitigate the risks of
using older software. There are a number of tools available to help with
this task, including gcr-cleaner. The gcr-cleaner tool is not an official Google product.
Assessing container security
The Center for Internet Security (CIS) has a Docker Benchmark for evaluating
the security of a Docker container.
Docker provides an open source script called Docker Bench for Security.
You can use the script to validate a running Docker container against the CIS
Docker Benchmark.
Docker Bench For Security can help you verify many items in the CIS Docker
Benchmark, but not all items are verifiable with the script.
For example, the script cannot verify if the host for the container is hardened
or if the container image includes personal data. Review all items in the
benchmark and identify those that might need additional verification.
Securing deployments
Learn about building a secure software supply chain and
how to use vulnerability scanning and Binary Authorization on Google Cloud to define
and enforce policies for deployment.
You can also watch a video that describes securing your software supply chain.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eThis page details best practices for building and managing container images, which directly impacts build and deployment speed, as well as maintenance efforts.\u003c/p\u003e\n"],["\u003cp\u003eWhen using images from public sources, it is recommended to build your own, use a standardized base image, scan for vulnerabilities, and enforce deployment policies to enhance security.\u003c/p\u003e\n"],["\u003cp\u003eBefore making registries public, ensure images are shareable, be aware of network egress costs, and consider capping per-user quota to prevent abuse.\u003c/p\u003e\n"],["\u003cp\u003eRemoving unused container images helps reduce storage costs and mitigate risks associated with using outdated software.\u003c/p\u003e\n"],["\u003cp\u003eUtilizing tools like Docker Bench for Security can help assess and improve the security of Docker containers, though some aspects require manual verification.\u003c/p\u003e\n"]]],[],null,["# Best practices for containers\n\nThis page provides information about best practices for building and running\ncontainer images.\n\nBuilding containers\n-------------------\n\nThe approach that you take to building container images can impact the\nspeed of builds and deployments, as well as the effort required to maintain\nyour images.\n\nRead the [Docker best practices](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/) for building images.\n\nConsiderations for public registries\n------------------------------------\n\nCarefully consider the following cases:\n\nUsing images from public sources\n\n: When you use images from public sources such as Docker Hub, you are\n introducing code that your organization does not control into your software\n supply chain. To mitigate risk, you can:\n\n - Build your own images to control image content.\n - Use a standardized base image and build on top of that image.\n - Scan images for vulnerabilities and address identified vulnerabilities.\n - Enforce standards and policies on images you deploy.\n\nMaking your registries public\n\n: You can make the registry in your Google Cloud project public by granting\n read access on the registry storage bucket to the `allUsers` identity.\n\n If all your users have Google Cloud accounts, you can limit access\n to authenticated users with the `allAuthenticatedUsers` identity instead.\n\n Consider the following guidelines before making a registry public:\n\n - Verify that all images you store in the registry are sharable publicly and do not expose credentials, personal data, or confidential data.\n - You are charged for [network egress](/container-registry/docs/pricing) when users pull images. If you expect a lot of internet download traffic, consider the associated costs.\n - By default, projects have unlimited per-user [quota](/container-registry/quotas). To prevent abuse, [cap](/docs/quotas/view-manage#capping_usage) per-user quotas within your project.\n\nRemoving unused images\n----------------------\n\nRemove unused container images to reduce storage costs and mitigate the risks of\nusing older software. There are a number of tools available to help with\nthis task, including [gcr-cleaner](https://github.com/sethvargo/gcr-cleaner). The gcr-cleaner tool is not an official Google product.\n| **Warning:** Do not use Cloud Storage \\[object lifecycle management\\] with Container Registry storage buckets. Lifecycle management does not work with images stored in Container Registry.\n\nAssessing container security\n----------------------------\n\nThe Center for Internet Security (CIS) has a [Docker Benchmark](https://www.cisecurity.org/benchmark/docker/) for evaluating\nthe security of a Docker container.\n\nDocker provides an open source script called [Docker Bench for Security](https://github.com/docker/docker-bench-security).\nYou can use the script to validate a running Docker container against the CIS\nDocker Benchmark.\n\nDocker Bench For Security can help you verify many items in the CIS Docker\nBenchmark, but not all items are verifiable with the script.\nFor example, the script cannot verify if the host for the container is hardened\nor if the container image includes personal data. Review all items in the\nbenchmark and identify those that might need additional verification.\n\nSecuring deployments\n--------------------\n\nLearn about building a [secure software supply chain](/software-supply-chain-security/docs/overview) and\nhow to use vulnerability scanning and Binary Authorization on Google Cloud to define\nand enforce policies for deployment.\n\nYou can also watch a video that describes securing your software supply chain."]]