在我的Manage Jenkins
>中Global Tool Configuration
,我已经配置了一个名为"docker"的工具,如下所示:
name: docker install automatically: CHECKED docker version: latest
然后我所拥有的jenkinsfile
就是以下内容,而不是其他内容:
node { DOCKER_HOME = tool "docker" sh """ echo $DOCKER_HOME ls $DOCKER_HOME/bin/ $DOCKER_HOME/bin/docker images $DOCKER_HOME/bin/docker ps -a """ }
我收到这样的错误" 无法连接到Docker守护程序.这个主机上是否运行了docker守护程序? ".
以下是完整的console log
:
Started by user Syed Rakib Al Hasan [Pipeline] node Running on master in /var/jenkins_home/workspace/helloDocker [Pipeline] { [Pipeline] tool [Pipeline] sh [helloDocker] Running shell script + echo /var/jenkins_home/tools/org.jenkinsci.plugins.docker.commons.tools.DockerTool/docker /var/jenkins_home/tools/org.jenkinsci.plugins.docker.commons.tools.DockerTool/docker + ls /var/jenkins_home/tools/org.jenkinsci.plugins.docker.commons.tools.DockerTool/docker/bin/ docker + /var/jenkins_home/tools/org.jenkinsci.plugins.docker.commons.tools.DockerTool/docker/bin/docker images Cannot connect to the Docker daemon. Is the docker daemon running on this host? [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline ERROR: script returned exit code 1 Finished: FAILURE
在管道到达运行docker命令的行之前,如何确保docker守护程序/服务正在运行/启动.
有没有其他本地docker-build-step插件方式来实现我在这里做的事情?像docker ps -a
或docker images
或docker build -t
?
假设我选择的节点尚未在我的主机中安装/运行docker/docker-engine.这是tool
命令在节点中自动安装docker 的目的(如果它尚未存在).