我正在关注詹金斯网站上的官方教程。我有一个蓝海码头容器,它正在Jenkinsfile中运行管道,如教程所示:
pipeline {
agent {
docker {
image 'node:6-alpine'
args '-p 3000:3000'
}
}
stages {
stage('Build') {
steps {
sh 'npm install'
}
}
}
}问题是当管道试图提取Docker映像时失败:
[ode-js-react-npm-app_master-6PEWX3VWDA4SAdDMJA4YKJCZSABJSAQCSGVYMKHINXGDDJLA] Running shell script
+ docker pull node:6-alpine
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?
script returned exit code 1经过一些故障排除后,我意识到这是失败的,因为Jenkins试图提取Docker容器本身,而不是主机。这不是我想要的,文件实际上说:
这个映像参数(代理部分的docker参数)下载节点:6-高寒码头映像(如果您的机器上还没有可用的话),并作为一个单独的容器运行这个映像。这意味着:您将在Docker中有单独的Jenkins和Node容器在本地运行。Node容器成为Jenkins用于运行管道项目的代理。然而,这个容器的使用时间很短--它的使用寿命仅限于管道执行的时间。
有人能解释我做错了什么吗?为什么Node.js码头形象被拉进詹金斯而不是本地机器?我希望有一个独立的Jenkins容器,而Nodejs容器负责编排这个应用程序。
发布于 2018-06-14 10:22:40
我通过以根用户身份运行容器来解决这个问题,否则它将无法访问Docker守护进程套接字/var/run/docker.sock .
https://stackoverflow.com/questions/50854825
复制相似问题