我让Jenkins在EC2实例上运行。我在对等VPC中配置了EC2插件,当作业标记为“ support_ubuntu_docker”时,它将启动Jenkins Slave,并预安装了Docker。
我能够按照示例操作,并让我的工作连接到在Slave上运行的本地docker,并在容器内运行命令。
工作:https://pastebin.com/UANvjhnA
pipeline {
agent {
docker {
image 'node:7-alpine'
label 'support_ubuntu_docker'
}
}
stages {
stage('Test') {
steps {
sh 'node --version'
}
}
}
}
不起作用https://pastebin.com/MsSZaPha
pipeline {
agent {
docker {
image 'hashicorp/terraform:light'
label 'support_ubuntu_docker'
}
}
stages {
stage('Test') {
steps {
sh 'terraform --version'
}
}
}
}
我尝试使用ansible / ansible:default图像以及我自己创建的图像。
FROM alpine:3.7
RUN apk add --no-cache terraform
RUN apk add --no-cache ansible
ENTRYPOINT ["/bin/ash"]
此图像在本地运行。
[jenkins_test] docker exec -it 3843653932c8 ash 10:56:42 ☁ master ☂ ⚡ ✭
/ # terraform --version
Terraform v0.11.0
/ # ansible --version
ansible 2.4.6.0
config file = None
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.15 (default, Aug 22 2018, 13:24:18) [GCC 6.4.0]
/ #
我真的只是想能够克隆我的terraform git repo,并使用容器中的terraform运行我的init / plan / applies。
对于所有这些错误即时消息是。
java.io.IOException: Failed to run top 'c9dfeda21b718b9df1035500adf2ef80c5c3807cf63e724317d620d4bcaa14b3'. Error: Error response from daemon: Container c9dfeda21b718b9df1035500adf2ef80c5c3807cf63e724317d620d4bcaa14b3 is not running
这个问题确实应该是Docker问题;node:7-alpine
和之间有什么区别hashicorp/terraform:light
?
hashicorp/terraform:light
有一个ENTRYPOINT
条目,指向/bin/terraform
。
基本上,这意味着您
docker run hashicorp/terraform:light --version
将以这种方式运行:并且它将立即退出,即,它不是交互式的。
因此,如果您想在该Docker容器内使用交互式外壳,则必须重写,ENTRYPOINT
以指向外壳,例如,/bin/bash
并告诉Docker交互式运行:
pipeline {
agent {
docker {
image 'hashicorp/terraform:light'
args '-it --entrypoint=/bin/bash'
label 'support_ubuntu_docker'
}
}
stages {
stage('Test') {
steps {
sh 'terraform --version'
}
}
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句