英文:
How can i establish connection between docker daemon on my machine and Jenkins to execute docker commands?
问题
我的 Jenkins 文件:
pipeline {
agent any
stages {
stage('初始化') {
steps {
script {
def dockerHome = tool 'myDocker'
env.PATH = "${dockerHome}/bin:${env.PATH}"
}
}
}
stage('构建') {
steps {
echo '构建后端...'
withGradle() {
sh './gradlew build'
}
}
}
stage('测试') {
steps {
echo '测试中'
}
}
stage('部署') {
steps {
echo '部署中'
sh './gradlew jibBuildTar'
sh 'docker load --input build/image.tar'
}
}
}
}
Jenkins 不允许我使用 docker 命令,因为 docker 守护程序未运行。我如何将我的守护程序连接到 Jenkins?我已经在 Jenkins 上安装了 docker 和 docker pipeline 插件。
英文:
My Jenkins file:
pipeline {
agent any
stages {
stage('Initialize') {
steps {
script {
def dockerHome = tool 'myDocker'
env.PATH = "${dockerHome}/bin:${env.PATH}"
}
}
}
stage('Build') {
steps {
echo 'building backend...'
withGradle() {
sh './gradlew build'
}
}
}
stage('Test') {
steps {
echo 'testing'
}
}
stage('Deploy') {
steps {
echo 'deploying'
sh './gradlew jibBuildTar'
sh 'docker load --input build/image.tar'
}
}
}
}
Jenkins does not let me use docker command because docker daemon is not running. How can i connect my daemon to jenkins?
i Have docker and docker pipeline plugins installed on jenkins too.
答案1
得分: 1
总结讨论:
默认情况下,Jenkins 在 master
节点上执行。必须在 master
节点上安装 Docker,并且需要允许 Jenkins 用户执行 Docker 命令(应将其添加到 docker 用户组中)。
英文:
Sum up of discussion:
By default Jenkins executes on master
node. Docker must be installed on master
node and Jenkins user needs to be allowed to execute docker commands (should be added to docker group).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论