[英]Jenkins Pipeline: Build docker within docker container
I'm trying to do the following我正在尝试执行以下操作
maven:3.6-jdk-8
maven:3.6-jdk-8
构建 jarDockerfile
to build app imageDockerfile
构建应用镜像Now, I don't want to install anything apart from Docker on Jenkins node.现在,我不想在 Jenkins 节点上安装除 Docker 之外的任何东西。 I want to run the full pipeline in Docker container to achieve this.
我想在 Docker 容器中运行完整的管道来实现这一点。 What I'm struggling is how to build the 4th step from within the container.
我正在努力的是如何从容器内构建第四步。
I wrote the Jenkinsfile as below我写的Jenkinsfile如下
pipeline {
agent none
stages {
stage('Maven build') {
agent {
docker {
image 'maven:3.6-jdk-8'
args '-u root:root'
}
}
steps {
checkout(
[
$class: 'GitSCM',
branches: [
[name: '*/master']
],
doGenerateSubmoduleConfigurations: false,
extensions: [],
submoduleCfg: [],
userRemoteConfigs: [
[
credentialsId: '<cred-id>',
url: '<github-url>']
]
])
sh '''
set -eux pipefail
mvn -e clean install
'''
}
}
stage('Build docker image') {
// Which docker image to use?
}
}
}
But I'm not sure how to build a docker image within container.但我不确定如何在容器中构建 docker 映像。 The search didn't help that much.
搜索并没有太大帮助。 I tried using the Jenkins node for the docker image building but it seems I cannot mix and match.
我尝试使用 Jenkins 节点来构建 docker 图像,但似乎我无法混合搭配。 I totally understand this is quite an open question but I think it would be helpful to know the straightforward answer(s).
我完全理解这是一个非常开放的问题,但我认为知道直截了当的答案会很有帮助。
Have a look at this Jenkins Plugin: https://docs.cloudbees.com/docs/admin-resources/latest/plugins/docker-workflow看看这个 Jenkins 插件: https://docs.cloudbees.com/docs/admin-resources/latest/plugins/docker-workflow
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.