Allowing your codespace to access a private image registry

You can use secrets to allow Codespaces to access a private image registry

Codespaces is available for organizations using GitHub Team or GitHub Enterprise Cloud. 更多信息请参阅“GitHub 的产品”。

About private image registries and Codespaces

A registry is a secure space for storing and managing private container images, such as Azure Container Registry or DockerHub. You can create secrets in GitHub to store the access details for a private registry and use them to give your codespace access to images stored in the registry.

When you launch a codespace, Codespaces checks for three secrets, which define the server name, username, and personal access token (PAT) for a container registry. If these secrets are found, Codespaces will make the registry available inside your codespace.


You can store secrets at the user, repository, or organization-level, allowing you to share them securely between different codespaces. When you create a set of secrets for a private image registry, you need to replace the “<*>” in the name with a consistent identifier. For more information, see "Managing encrypted secrets for your codespaces" and "Managing encrypted secrets for your repository and organization for Codespaces."

If you are setting the secrets at the user or organization level, make sure to assign those secrets to the repository you'll be creating the codespace in by choosing an access policy from the dropdown list.

Image registry secret example

Example secrets

For a private image registry in Azure, you could create the following secrets:


For information on common image registries, see "Common image registry servers."

Image registry secret example

Once you've added the secrets, you may need to stop and then start the codespace you are in for the new environment variables to be passed into the container. For more information, see "Suspending or stopping a codespace."

Common image registry servers

Some of the common image registry servers are listed below:



所有 GitHub 文档都是开源的。看到错误或不清楚的内容了吗?提交拉取请求。


或, 了解如何参与。