Jenkins Pipeline Docker -- Container is Not Running

In a scripted pipeline you can do this:

docker.image(dockerImage).inside("--entrypoint=''") {
    // code to run on container
}

If you are creating the image to use in Jenkins from a base image that already has an ENTRYPOINT instruction, you can override it by adding this line to the end of your own Dockerfile:

ENTRYPOINT []

Then the whole --entrypoint is no longer needed.


The question really should have been a Docker question; what's the difference between node:7-alpine and hashicorp/terraform:light?

hashicorp/terraform:light has an ENTRYPOINT entry, pointing to /bin/terraform.
Basically that means you run it this way:
docker run hashicorp/terraform:light --version
And it will exit right away, i.e., it's not interactive.
So if you want an interactive shell within that Docker container, you'll have to override the ENTRYPOINT to point at a shell, say, /bin/bash and also tell Docker to run interactively:

pipeline {
    agent {
        docker { 
            image 'hashicorp/terraform:light' 
            args '-it --entrypoint=/bin/bash'
            label 'support_ubuntu_docker'
        }
    }
    stages {
        stage('Test') {
            steps {
                sh 'terraform --version'
            }
        }
    }
}