我有一个jenkins声明式管道构建,它运行gradle并使用gradle插件创建docker映像。我还使用了dockerfile代理指令,因此整个过程都运行在docker容器中。这与jenkins本身安装在docker (我知道,那是很多docker)中工作得很好。我在docker for mac上的docker容器中安装了jenkins,每个https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/都有-v /var/run/docker.sock:/var/run/docker.sock (DooD)。通过这种设置,管道docker代理运行得很好,管道docker代理中的docker build命令也运行得很好。我假设jenkins也将docker socket安装在其内部docker容器上。
现在,我尝试在安装了docker的ec2实例上的jenkins上运行它。jenkins用户将docker组作为其主要组。jenkins用户能够成功运行"docker run hello-world“。我的管道构建启动了docker agent容器(基于添加了各种内容的gradle镜像),但是当gradle尝试运行docker build命令时,我得到了以下结果:
* What went wrong:
Execution failed for task ':docker'.
> Docker execution failed
Command line [docker build -t config-server:latest /var/lib/****/workspace/nfig-server_feature_****-HRUNPR3ZFDVG23XNVY6SFE4P36MRY2PZAHVTIOZE2CO5EVMTGCGA/build/docker] returned:
Cannot connect to the Docker daemon. Is the docker daemon running on this host?可以使用声明性管道在docker代理中构建docker镜像吗?
发布于 2018-01-21 19:28:38
是的,是这样的。
问题不在于Jenkins的声明性管道,而在于您如何设置和运行程序。
从上面的错误看,似乎缺少需要授予的权限。
也许如果你分享你的配置和你的运行方式,更多的人可以提供帮助。
https://stackoverflow.com/questions/43534664
复制相似问题