我对Jenkins来说是个新手。我尝试了几个基本的管道示例,它们是有效的。
我的具体用例如下:
我在docker hub存储库中有一个基本镜像: my_dockerhub_rep/myImage:v1
现在,我想通过Jenkins管道在这个基础映像的基础上构建另一个映像。所以我写了下面的dockerfile:
FROM my_docker_hub_rep/myImage:v1
RUN /bin/bash -c 'echo entering in MC container'为了从Jenkins构建此镜像,我编写了以下Jenkinsfile:
pipeline {
agent { dockerfile {
filename "/home/user/Desktop/Dockerfile"
registryUrl ""
registryCredentialsId 'dockerHub'
}}
stages {
stage('Build') {
steps {
echo 'hello !'
sh 'echo LM_LICENSE_FILE = $LM_LICENSE_FILE'
}
}jenkins服务器一开始可以成功登录到docker存储库,但是一旦它尝试获取基本映像,它就会抛出一个错误,即拒绝拉访问:存储库不存在或需要docker登录。
我不明白的是,如果它可以登录到docker repo一次,那么为什么不能再次登录?
以下是jenkins的控制台输出:
Started by user unknown or anonymous
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/docker_test
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] withDockerRegistry
$ docker login -u mydockerID-p ******** https://index.docker.io/v1/
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /var/lib/jenkins/workspace/docker_test@tmp/a548cbfa-5d55-4a2c-87a7-4954052d7e5b/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Agent Setup)
[Pipeline] isUnix
[Pipeline] readFile
[Pipeline] sh
+ docker build -t b2f2e9020bdfdbcd1bc3d0a6f0f28b1c7abff41b -f /home/user/Desktop/Dockerfile .
Sending build context to Docker daemon 2.095kB
Step 1/8 : FROM my_docker_rep/myImage:v1
pull access denied for my_docker_rep/myImage, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withDockerRegistry
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILUREps:我已经将jenkins添加到用户组中了。
发布于 2020-03-22 18:54:50
您的docker文件应该有一个完整的图像引用。<registry>/<repository>/<imagename>:<image_tag>如果不是,docker后台程序将始终尝试从默认docker注册表中提取图像。更改DOCKERFILE的FROM部分,使其包含完整的图像路径。看起来不错
https://stackoverflow.com/questions/60779473
复制相似问题