不能让jenkinsdocker奴隶build立docker图像

我目前正在与Jenkins一起试验Docker,以简化新项目的CI / CD工作stream程。 我在安装了Docker 1.12的Mac上这样做。

这就是我所做的:

  1. 使用docker机创build一个新的docker服务器
  2. 使用官方Jenkins Docker镜像在该服务器上创build一个Jenkins实例
  3. 安装“又一个Docker插件”和“CloudBees Dockerpipe道”插件。
  4. 使用上面的Docker服务器的IP和第三方Docker DinD镜像添加一个“Docker Cloud”镜像tehranian / dind-jenkins-slave

有了这个设置,我运行了一个非常简单的stream水线作业:

node('docker') { docker.image('hseeberger/scala-sbt').inside { stage 'Checkout' echo 'We got here!' } } 

Jenkins按预期旋转Docker实例并执行作业。 所以基本的Docker设置按预期工作。

但作业中的Docker命令失败。 日志输出如下所示:

 [Pipeline] node Still waiting to schedule task Docker-23ebf3d8dd4f is offline Running on Docker-23ebf3d8dd4f in /home/jenkins/workspace/docker-test [Pipeline] { [Pipeline] sh [docker-test] Running shell script + docker inspect -f . hseeberger/scala-sbt Cannot connect to the Docker daemon. Is the docker daemon running on this host? [Pipeline] sh [docker-test] Running shell script + docker pull hseeberger/scala-sbt Using default tag: latest Warning: failed to get default registry endpoint from daemon (Cannot connect to the Docker daemon. Is the docker daemon running on this host?). Using system default: https://index.docker.io/v1/ Cannot connect to the Docker daemon. Is the docker daemon running on this host? [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline 

现在,当我浏览解决scheme时,通常会提到Docker套接字需要作为卷提供给容器,但似乎也不起作用。

由于一般的设置似乎正在工作,奴隶不是简单地做同样的事情,jenkins插件起到旋转docker奴隶摆在首位? 也就是说,使用Docker服务器的URL来控制它? 因为我认为这是一个非常常见的用例,所以Jenkins Docker从站必须有一个Docker镜像,可以这样做,对吗? 我错过了什么?

您可能需要设置docker env,并在运行的shell脚本中使用docker-machine env node的内容。