[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-18。"],[[["\u003cp\u003eVirtual repositories offer a unified access point for downloading and installing artifacts from multiple upstream repositories, simplifying client configurations.\u003c/p\u003e\n"],["\u003cp\u003eVirtual repositories enhance dependency resolution safety by enabling the prioritization of upstream repositories, mitigating the risk of dependency confusion attacks.\u003c/p\u003e\n"],["\u003cp\u003eArtifact Registry uses a priority system based on integer values to determine which upstream repository to use when the requested artifact is available in multiple locations.\u003c/p\u003e\n"],["\u003cp\u003eVirtual repositories are supported for various Artifact Registry repository formats, including Docker, Maven, npm, Python, Apt, and Yum, among others.\u003c/p\u003e\n"],["\u003cp\u003eVirtual repositories have certain limitations including Maven virtual repositories not permitting specific version policies, and Apt and Yum standard repositories having asynchronous package index updates.\u003c/p\u003e\n"]]],[],null,["# Virtual repositories overview\n\nThis document provides an overview of virtual repositories. For instructions on\nhow to create a virtual repository, see\n[Create virtual repositories](/artifact-registry/docs/repositories/virtual-repo).\n\nArtifact Registry\n[Quotas and limits](/artifact-registry/quotas) apply to virtual repositories.\n\nHow virtual repositories work\n-----------------------------\n\nVirtual repositories act as a single access point to download, install, or\ndeploy artifacts in the same format from one or more *upstream repositories*.\nAn upstream repository can be a Artifact Registry standard or remote\nrepository.\n\nThe other repository modes are:\n\n- [Standard](/artifact-registry/docs/repositories): The default repository mode. You upload or publish artifacts such as private packages directly to standard repositories. Although you can download directly from individual standard repositories, accessing groups of repositories with a virtual repository simplifies tool configuration.\n- [Remote](/artifact-registry/docs/repositories/remote-overview) (language package repositories only): A pull through cache for artifacts in public repositories such as Maven Central or PyPI. It acts as a proxy for the public repositories so that you have more control over your external dependencies.\n\nUse cases and benefits\n----------------------\n\nSimpler client configuration\n\n: For task that only requires read access to repositories, you only need to\n configure a single Artifact Registry repository to access artifacts\n stored in multiple upstream repositories.\n\n For example:\n\n - A virtual repository for Maven packages can serve private Java packages from a Artifact Registry standard repository and public Java packages from a remote repository that caches public packages from Maven Central.\n - A virtual repository can serve private Python packages from multiple upstream standard repositories owned by different teams. Each team has write access to their upstream repository, but downloads packages from other teams using the virtual repository.\n\nSafer dependency resolution\n\n: You can assign a priority to upstream repositories to have more control over\n which repository Artifact Registry chooses when a requested artifact is\n in more than one upstream repository.\n\n Some tools, such as the Python `pip` tool, do not provide a way to control\n search order when a mix of private and public repositories are configured in\n the client. This type of configuration is vulnerable to a\n *dependency confusion* attack, where someone uploads a new version of a\n package with bad code to a public repository to trick clients into choosing\n the bad version.\n\n You can use remote and virtual repositories together to mitigate this risk:\n\n 1. Create a remote repository as a proxy for the public repository.\n 2. Create a standard repository for your private packages.\n 3. Create a virtual repository that is configured to prioritize your standard repository if a version of the same package exists in both repositories.\n 4. Configure package managers and other tools to read from the virtual repository only, so that the client logic is not involved repository selection.\n\nTo learn about other dependency management best practices, see\n[Dependency management](/software-supply-chain-security/docs/dependencies).\n\nHow virtual repositories select an upstream repository\n------------------------------------------------------\n\nEach upstream repository must have a configured *priority*. The priority is\nan integer that acts as a weight, not a ranking. This means that repositories\nwith a higher priority value are prioritized over repositories with lower\npriority values.\n\nWhen you request an artifact that is in multiple upstream repositories,\nArtifact Registry uses the following prioritization logic:\n\n- The repository with the highest value is prioritized. For example, a value of `10` is treated as higher priority than a value of `1`.\n- If multiple upstream repositories have the same priority, the artifact can be served from any of those repositories.\n\nWhen you directly configure a client to search a virtual repository and\nadditional repositories, the client might still download artifacts from\nrepositories outside of Artifact Registry.\n\nFor example, if you configure the Python `pip` tool to search PyPI and a virtual\nrepository, your package might be downloaded directly from PyPI because `pip`\nwill always choose the latest version of a package, regardless of which\nrepository it comes from. If `pip` is configured to only search the virtual\nrepository, you can then control the priority of all upstream repositories,\nincluding an upstream remote repository that acts as a proxy for PyPI.\n\nSupported repository formats\n----------------------------\n\nYou can create virtual repositories for following Artifact Registry\nArtifact Registry repository formats:\n\nLanguage packages:\n\n- [Docker](/artifact-registry/docs/docker)\n- [Go](/artifact-registry/docs/go)\n- [Maven](/artifact-registry/docs/java)\n- [npm](/artifact-registry/docs/nodejs)\n- [Python](/artifact-registry/docs/python)\n\nOS packages:\n|\n| **Private Preview**\n|\n|\n| This product or feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA products and features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\n- [Apt](/artifact-registry/docs/os-packages/debian)\n- [Yum](/artifact-registry/docs/os-packages/rpm)\n\nIf you are new to Artifact Registry, you can use the quickstarts to learn\nabout setting up standard repositories for these formats.\n\nLimitations\n-----------\n\nIn addition to Artifact Registry quotas and limitations, virtual\nrepositories have the following limitations:\n\n- Standard Artifact Registry upstream repositories must be in the same region or multi-region as the virtual repository, but can be in different Google Cloud projects.\n- Maven virtual repositories don't permit setting the version policy to snapshot\n or release.\n\n- Apt and Yum upstreams must be Artifact Registry standard repositories.\n\n- Apt and Yum standard repositories update the package index asynchronously\n after a package is imported, uploaded, or deleted. For small repositories,\n regenerating the index can take several seconds. For larger repositories,\n reindexing might take several minutes or longer. After reindexing is complete,\n the change to the repository is visible to Apt and Yum clients.\n\nWhat's next\n-----------\n\n- [Create virtual repositories](/artifact-registry/docs/repositories/virtual-repo).\n- Learn more about Artifact Registry repositories by reading the [Repository overview](/artifact-registry/docs/repositories)."]]