在jenkins上使用docker插件 - [英] using docker plugin on jenkins -

查看:279
本文介绍了在jenkins上使用docker插件 - 的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用Jenkins上的docker插件运行一个现有容器的实例。
Docker版本1.6.0,build 4749651



我选择了创建容器
输入图像名称的图像ID,并尝试主持人 http://172.16.42.43:4243 ,并尝试一个空的主机。
我不断得到这个错误:

 错误:构建步骤失败,异常
java.lang.NullPointerException :未指定uri
com.google.common.base.Preconditions.checkNotNull(Preconditions.java:204)
在com.github.dockerjava.core.DockerClientConfig $ DockerClientConfigBuilder.withUri(DockerClientConfig.java :406)
在org.jenkinsci.plugins.dockerbuildstep.DockerBuilder $ DescriptorImpl.createDockerClient(DockerBuilder.java:123)
在org.jenkinsci.plugins.dockerbuildstep.DockerBuilder $ DescriptorImpl.getDockerClient(DockerBuilder.java :201)
在org.jenkinsci.plugins.dockerbuildstep.DockerBuilder.perform(DockerBuilder.java:71)
在hudson.tasks.BuildStepMonitor $ 1.perform(BuildStepMonitor.java:20)
在hudson.model.AbstractBuild $ AbstractBuildExecution.perform(AbstractBuild.java:779)
在hudson.model.Build $ BuildExecution.build(Build.java:205)
在hudson.model.Build $ BuildExecution .doRun(Build.j ava:162)
在hudson.model.AbstractBuild $ AbstractBuildExecution.run(AbstractBuild.java:537)
在hudson.model.Run.execute(Run.java:1744)
在哈德森.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
在hudson.model.ResourceController.execute(ResourceController.java:98)
在hudson.model.Executor.run(Executor.java:374 )
构建步骤'执行Docker容器'标记的构建为失败

有人可以告诉我要解决这个问题?
此外,如果有人以前使用过此插件,请让我知道这是否有效。



还尝试了执行docker容器 - >启动容器ID指定的容器导致相同的错误。



另一种方法:
我尝试使用Execute shell插件,我收到此错误:

  + docker start d023eec1ff34 
发布http:///var/run/docker.sock/v1.18/ container / d023eec1ff34 / start:dial unix /var/run/docker.sock:permission denied。您是否尝试连接到不带TLS的启用TLS的守护程序?
time =2015-05-05T10:26:34-07:00level = fatal msg =错误:无法启动一个或多个容器
pre>

如果我只是去终端,切换到jenkins用户并运行docker start命令,它工作正常。
如果有人知道如何以这种方式解决这个问题,那也是很棒的。

解决方案

假设Docker正在运行在同一台机器上,确保运行Docker:



-H tcp://127.0.0.1:4243 -H unix:// /var/run/docker.sock



然后转到管理Jenkins>配置>配置系统,然后向下滚动到 Docker Builder ,并且在Docker服务器REST URL 中输入 http:// localhost:4243



已编辑:我原来告诉Docker在0.0.0.0上收听所有IP地址的绑定,如果您的防火墙允许流量通过,可以允许外部连接。所以我更新了它来绑定到环回地址。此外,当前版本的文档建议使用不同的端口,但是由于您手动指定端口将执行的端口。


I'm trying to use the docker plugin on Jenkins to run an instance of an existing container. Docker version 1.6.0, build 4749651

I've chosen "create container" Entered the image id for the image name, and tried a host http://172.16.42.43:4243 and also tried an empty host. I keep getting this error:

ERROR: Build step failed with exception
java.lang.NullPointerException: uri was not specified
    at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:204)
    at com.github.dockerjava.core.DockerClientConfig$DockerClientConfigBuilder.withUri(DockerClientConfig.java:406)
    at org.jenkinsci.plugins.dockerbuildstep.DockerBuilder$DescriptorImpl.createDockerClient(DockerBuilder.java:123)
    at org.jenkinsci.plugins.dockerbuildstep.DockerBuilder$DescriptorImpl.getDockerClient(DockerBuilder.java:201)
    at org.jenkinsci.plugins.dockerbuildstep.DockerBuilder.perform(DockerBuilder.java:71)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
    at hudson.model.Build$BuildExecution.build(Build.java:205)
    at hudson.model.Build$BuildExecution.doRun(Build.java:162)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:537)
    at hudson.model.Run.execute(Run.java:1744)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:374)
Build step 'Execute Docker container' marked build as failure

Can someone tell me how to fix it? Also, if anyone has used this plugin before, please let me know if this has ever worked.

Also tried the "Execute docker container"->start containers with the container id specified resulting in the same error.

Another approach: I tried using the Execute shell plug in and I'm getting this error:

+ docker start d023eec1ff34
Post http:///var/run/docker.sock/v1.18/containers/d023eec1ff34/start: dial unix /var/run/docker.sock: permission denied. Are you trying to connect to a TLS-enabled daemon without TLS?
time="2015-05-05T10:26:34-07:00" level=fatal msg="Error: failed to start one or more containers"

If I just go to the terminal, switch to jenkins user and run the docker start command, it works fine. If someone know how to fix it this way, that would be great as well.

解决方案

Assuming Docker is running on the same machine, make sure to run Docker with:

-H tcp://127.0.0.1:4243 -H unix:///var/run/docker.sock

Then go to Manage Jenkins > Configuration > Configure System then scroll down to Docker Builder and in the Docker server REST url enter http://localhost:4243

Edited: I had originally told Docker to listen on 0.0.0.0 which binds to all IP addresses and could allow connections from the outside if your Firewall lets the traffic through. So I updated it to bind to the loopback address instead. Also, the current version of the documentation recommends a different port but since you specify the port manually any port will do.

这篇关于在jenkins上使用docker插件 - 的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆