sh step within container step does not work when user is non-root

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      Attempting to execute sh command within container step fails when the image user is not root.

      Replicate by running pipeline:

      podTemplate(name: 'my-pod', label: 'my-pod',
        containers: [
          containerTemplate(name: 'kubectl-cmd', 
                            image: 'wernight/kubectl:1.6.4',
                            ttyEnabled: true, 
                            command: 'cat', args:null)]) {
            node('my-pod') {
              stage('Test command') {
                container('kubectl-cmd') {
                  sh 'whoami'
                }
              }
            }
      } 

      `sh 'whoami'` does not successfully run, and the job fails with message: "ERROR: script returned exit code -2 "

      The image being run is here.

      I created a modified version of the image where simply "User kubectl" is removed. The job then runs as expected.

       

       

            Assignee:
            Unassigned
            Reporter:
            Chris Willmore
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Resolved:
              Archived: