Dockerfile entrypoint failing in Jenkins pipeline

Viewed 2436

How does the Jenkins Dockerfile agent work?

I've defined my Dockerfile as

FROM hashicorp/terraform:latest
ENTRYPOINT ["terraform"]

And my Jenkinsfile as

pipeline {
    agent { 
        dockerfile true
    }
    stages {
        stage('Example') {
            steps {
                sh 'terraform version'
            }
        }
    }
    post { 
        always { 
            cleanWs()
        }
    }
}

But I keep getting an error in the console output asking me to check my ENTRYPOINT

ErrorMessage:

ERROR: The container started but didn't run the expected command. Please double check your ENTRYPOINT does execute the command passed as docker run argument, as required by official docker images (see https://github.com/docker-library/official-images#consistency for entrypoint consistency requirements).
Alternatively you can force image entrypoint to be disabled by adding option `--entrypoint=''`.

I've looked at the documentation but I can't seem to make sense of it.

What I expect to happen is that Jenkins will build the hashicorp/terraform image which I can then use as a build agent without having to install terraform on my server, but I seem to be doing something wrong.

Does anyone understand how this works?

0 Answers
Related