我如何在jenkins中向Docker管道添加身份验证凭据?

问题描述 投票:0回答:1

[我很熟悉如何使用docker管道在jenkins上的docker容器中运行作业,但是到目前为止,它对于不需要任何身份验证凭据从注册表中提取图像的公共docker镜像非常有用

https://jenkins.io/doc/book/pipeline/docker/

所以可以说我有这个例子

pipeline {
    agent {
        docker { 
                 image 'private.docker.local/node:7-alpine' 
                 args '--net=host  -u root'
               }
    }
    stages {
        stage('Test') {
            steps {
                sh 'node --version'
            }
        }
    }
}

当我尝试得到错误时

+ docker pull private.docker.local/node:7-alpine

Error response from daemon: Get https://private.docker.local/v2/node:7-alpine/manifests/7-alpine: denied: access forbidden

任何人都知道如何添加身份验证,以便docker管道可以登录到docker注册表以提取图像?

jenkins docker-registry jenkins-job-dsl
1个回答
0
投票
实际上终于在这里找到答案https://jenkins.io/doc/book/pipeline/syntax/#agent

pipeline { agent { docker { alwaysPull true image 'private.docker.local/node:7-alpine' args '--net=host -u root' registryUrl 'https://private.docker.local/' registryCredentialsId 'registry-credential' } } stages { stage('Test') { steps { sh 'node --version' } } } }

© www.soinside.com 2019 - 2024. All rights reserved.