Container hangs in podTemplate in jenkinsfile

I am using the below podTemplate in my jenkinsfile/pipeline:

podTemplate(label: 'builder',
            imagePullSecrets: [ 'mypull-secret' ],
            containers: [
                    containerTemplate(name: 'jnlp', image: 'jenkins/inbound-agent:4.9-1', args: '${computer.jnlpmac} ${computer.name}'),
                    containerTemplate(name: 'gradle', image: 'gradle:latest', command: 'cat', ttyEnabled: true),
                    containerTemplate(name: 'sample-image', image: 'internalreg/samples/sample-image:latest', command: 'cat', ttyEnabled: true)
            ],
            volumes: [
                    hostPathVolume(hostPath: '/var/run/docker.sock', mountPath: '/var/run/docker.sock')
            ]) {

        node('builder') {

            stage('Checkout') {
                checkout scm
            }

            stage('Gradle') {
              container('gradle') {
                sh "./gradlew --version"
              }
            }

            stage('Sample image') {
              container('sample-image') {
                sh "ls -la"
              }
            }

        }
    }

But when I run the above in jenkins it just hangs at the Sample image stage.

[Pipeline] { (Sample image) (hide)
[Pipeline] container
[Pipeline] {
[Pipeline] sh

How do I configure a containerTemplate for my own custom docker container?

I’m not super familiar in this, I tend to use generic docker now the k8s integration.

so in my experience, that freeze is usually jenkins trying to talk to the container and it can’t.

Assuming your docker image has an entrypoint, make sure it it allows arbitrary commands (like cat) to be run. if it doesn’t, you might want to override the entrypoint in your containerTemplate to emptystring.

What do you mean by generic docker/k8s integration?

I’ve just done

then used k8s cloud templates, that way i could switch to using cloud agents, or ssh agents, or whatever else without having to worry about rewriting jenkinsfiles.