詹金斯:无法连接到Docker Daemo
我想用詹金斯创建一个码头图像,但无法连接到Docker守护程序。
这是我的管道
pipeline {
agent any
options { buildDiscarder(logRotator(numToKeepStr:'5'))}
environment {DOCKERHUB_CREDENTIALS = credentials('tfkben-dockerhub')}
stages {
stage('build'){ steps { sh 'docker build -t tfkben/ben:latest .' } }
stage('Login'){ steps { sh 'echo $DOCKERHUB_CREDENTIALS_PSW | docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin ' }}
stage('Push'){ steps { sh 'docker push tfkben/ben:latest'} }
}
post { always { sh 'docker logout' }}
} 我的dockerfile:
FROM python:3.11-rc-bullseye
WORKDIR /app
COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt
COPY . .
CMD [ "python3", "manage.py", "runserver", "0.0.0.0:8000"]
and this is the error message :
- docker build -t tfkben/ben:最新。 无法通过TCP:// Docker:2376连接到Docker守护程序。 Docker守护程序在运行吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
@Toufik Benkhelifa看来,您的Jenkins代理商中没有安装Docker。您的Jenkins代理商在哪里?这里有几种可能性。
参考: https://docs.docker.com/engine/engine/install/
让您说您同时将Jenkins Master和Jenkins Agent作为Docker节点运行。
在哪里,
现在,将Jenkins Master与Docker主持人Daemon链接。为此,您需要使用“ docker插件for jenkins” https://plugins.jenkins.jenkins.jenkins.jenkins .io/docker-plugin/
此Docker插件的目的是能够使用Docker主机动态地提供Docker容器作为Jenkins Agent Node,让该运行单个构建,然后将其拆除,然后拆下来节点,没有构建过程(或詹金斯的作业定义),需要对Docker的任何认识。
安装插件后,我们要做的就是配置Jenkins,以添加Jenkins的新云 - >管理 - >系统配置并将新云添加为“ Docker”
,最后,如前所述,Docker恶魔将在上运行,
其中需要是Docker主机URI
参考:https://blog.executeautomation.com/running-jenkins-build-agent-within-docker-container-part- A/
@Toufik Benkhelifa It seems you don't have docker installed in your jenkins agent. Where is your Jenkins agent is resided? There are couple of possibilities here.
Reference: https://docs.docker.com/engine/install/
Lets say you have both Jenkins master and Jenkins agent running as docker nodes.
Where,
Now, Link Jenkins Master with Docker Host Daemon. In order to do that, you need to use "Docker plugin for Jenkins" https://plugins.jenkins.io/docker-plugin/
The aim of this docker plugin is to be able to use a Docker host to dynamically provision a docker container as a Jenkins agent node, let that run a single build, then tear-down that node, without the build process (or Jenkins job definition) requiring any awareness of docker.
Once the plugin is installed, all we need to do is to configure Jenkins to add new cloud from Jenkins -> Manage -> System configuration and add new cloud as 'Docker'
Finally, as mentioned earlier, the Docker demon will be running on
which needs to be the Docker Host URI
Reference : https://blog.executeautomation.com/running-jenkins-build-agent-within-docker-container-part-a/
这很可能是由于您的Jenkins代理商没有Docker守护程序在其中。
如果代理本身作为Docker容器运行,则需要确保其使用具有“ Docker-In-indocker”的图像(DIND)
It is likely due to your Jenkins agent not having a Docker daemon running within it.
If the agent itself is running as a Docker container, then you need to ensure that it uses an image that has “Docker-in-Docker” (dind)