

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 为自托管运行程序配置私有注册表凭证
<a name="private-registry-sample-configure-runners"></a>

按照以下说明为自托管运行程序配置注册表凭证。

**注意**  
请注意，只有当映像被私有注册表中的映像覆盖时，才会使用这些凭证。

------
#### [ AWS Management Console ]

1. 在 [https://console.aws.amazon.com/codesuite/codebuild](https://console.aws.amazon.com/codesuite/codebuild/home) /home 中打开 AWS CodeBuild 控制台。

1. 创建构建项目或选择现有项目。有关更多信息，请参阅 [创建构建项目（控制台）](create-project.md#create-project-console) 和 [更改构建项目的设置（控制台）](change-project.md#change-project-console)。

1.  在**环境**中，选择**其他配置**。

1.  在**其他配置**中，输入**注册凭据的密钥名称或 ARN（ AWS Secrets Manager 可选**）。  
![注册表凭证配置。](http://docs.aws.amazon.com/zh_cn/codebuild/latest/userguide/images/registry-credential.png)

------
#### [ AWS CLI ]

1. 如果要创建一个新项目，请运行 **create-project** 命令。

   ```
   aws codebuild create-project \
       --name {{project-name}} \
       --source type={{source-type}},location={{source-location}} \
       --environment "type={{environment-type}},image={{image}},computeType={{compute-type}},registryCredential={credentialProvider=SECRETS_MANAGER,credential={{secret-name-or-arn}}},imagePullCredentialsType=CODEBUILD|SERVICE_ROLE" \
       --artifacts type={{artifacts-type}} \
       --service-role arn:aws:iam::{{account-ID}}:role/service-role/{{service-role-name}}
   ```

1. 如果要更新现有项目，请运行 **update-project** 命令。

   ```
   aws codebuild update-project \
       --name {{project-name}} \
       --environment "type={{environment-type}},image={{image}},computeType={{compute-type}},registryCredential={credentialProvider=SECRETS_MANAGER,credential={{secret-name-or-arn}}}"
   ```

------