如何通过Jenkins容器从Docker Hub提取图像

时间:2019-08-30 10:58:27

标签: image docker jenkins containers

我在docker中构建了一个Jenkins容器,我想在Jenkins作业中从docker hub构建一个容器(例如:ubuntu),但是失败了,控制台输出显示从docker镜像ubuntu:latest提取失败。这里有问题吗?

请帮助我,谢谢!

这是控制台输出:

Running as SYSTEM
Building in workspace /var/jenkins_home/workspace/pull_docker_image
Pull Docker image ubuntu:latest from repository ...
$ /var/jenkins_home/tools/org.jenkinsci.plugins.docker.commons.tools.DockerTool/docker/bin/docker pull ubuntu:latest
Failed to pull Docker image ubuntu:latest
--------------------------------------------------------
FATAL: Failed to pull Docker image ubuntu:latest
------------------------------------------------------------------
java.io.IOException: Failed to pull Docker image ubuntu:latest
    at com.cloudbees.jenkins.plugins.docker_build_env.PullDockerImageSelector.prepareDockerImage(PullDockerImageSelector.java:34)
    at com.cloudbees.jenkins.plugins.docker_build_env.DockerBuildWrapper.setUp(DockerBuildWrapper.java:179)
    at hudson.model.Build$BuildExecution.doRun(Build.java:157)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
    at hudson.model.Run.execute(Run.java:1815)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:429)
Finished: FAILURE

这是我的配置: enter image description here

1 个答案:

答案 0 :(得分:0)

在运行具有jenkins的容器时,是否将其docker.sock绑定到托管操作系统之一,以便从jenkins容器运行docker命令?

TASK [AwsS3] 
**********************************
"s3_keys": [
        "folder/bambu/bambu-338400da-1.tgz", 
        "folder/bonsai/bonsai-0de3166b-1.tgz", 
        "folder/sakura/sakura-1236s38f-1.tgz",
        "folder/sakura/sakura-342bd38f-2.tgz", 
        "folder/sakura/sakura-4567888f-3.tgz",
        "folder/sakura/sakura-678338sf-4.tgz", 
        "folder/shibazakura/shibazakura-1f5273e8-1.tgz",
        "folder/shibazakura/shibazakura-123asde8-2.tgz", 
        "folder/shibazakura/shibazakura-asdqwee8-3.tgz", 
        "folder/ume/ume-3164f62c-1.tgz",
        "folder/ume/ume-4c12312c-2.tgz",

TASK [CountFilesS3Folder] 
**********************************
ok: [localhost] => {
    "msg": "11"

如果这是解决问题的方法,则可能还需要/var/run/docker.sock具有正确的权限。

让我知道。