I have Jenkins running on an EC2 Instance. I have the EC2 Plugin Configured in a Peered VPC, and when a job is tagged 'support_ubuntu_docker' it will spin up an Jenkins Slave, with Docker pre-installed.

I am able to follow the examples, and get my job to connect to the local docker running on the Slave, and run commands inside the container.

Working: https://pastebin.com/UANvjhnA

pipeline {
    agent {
        docker { 
            image 'node:7-alpine' 
            label 'support_ubuntu_docker'
             }
    }
    stages {
        stage('Test') {
            steps {
                sh 'node --version'
            }
        }
    }
}

Not Working https://pastebin.com/MsSZaPha

pipeline {
    agent {
        docker { 
            image 'hashicorp/terraform:light' 
            label 'support_ubuntu_docker'
             }
    }
    stages {
        stage('Test') {
            steps {
                sh 'terraform --version'
            }
        }
    }
}

I have tried with the ansible/ansible:default image, as well as a image I created myself.

FROM alpine:3.7
RUN apk add --no-cache terraform
RUN apk add --no-cache ansible
ENTRYPOINT ["/bin/ash"]

This image behaves locally.

[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]
/ # 

I really just want to be able to clone my terraform git repo, and use the terraform in the container to run my init/plan/applies.

The error im getting for all of these is.

java.io.IOException: Failed to run top 'c9dfeda21b718b9df1035500adf2ef80c5c3807cf63e724317d620d4bcaa14b3'. Error: Error response from daemon: Container c9dfeda21b718b9df1035500adf2ef80c5c3807cf63e724317d620d4bcaa14b3 is not running

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.