gpt4 book ai didi

docker - 如何在 Jenkins 管道中使用多个 docker 存储库

转载 作者:行者123 更新时间:2023-12-02 18:00:43 24 4
gpt4 key购买 nike

我有一个 Jenkins 管道,我需要在其中登录到两个不同的 docker 存储库。我知道如何使用以下命令对一个 repo 进行身份验证

docker.withRegistry('https://registry.example.com', 'credentials-id')

但不知道如何处理超过 1 个 repo ?

最佳答案

嵌套 docker.withRegistry调用实际上按预期工作。每次调用都会向 /home/jenkins/.dockercfg 添加一个条目提供凭据。

// Empty registry ('') means default Docker Hub `https://index.docker.io/v1/`
docker.withRegistry('', 'dockerhub-credentials-id') {
docker.withRegistry('https://private-registry.example.com', 'private-credentials-id') {
// your build steps ...
}
}
这允许您使用提供的凭据从 Docker Hub 拉取基础镜像,以避免最近引入的拉取限制,并将结果推送到另一个 docker 注册表中。

关于docker - 如何在 Jenkins 管道中使用多个 docker 存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57167072/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com