title: Jenkins docker agent pipeline without root
body: <p>I have a Jenkinsfile with a very basic pipeline that spins up a docker container:</p>
  
  <pre><code>pipeline {
  
    agent { dockerfile { args '-u root' } }
  
    stages {
      stage('Test') {
        steps {
          echo 'Testing...'
          sh 'whoami'
        }
      }
    }
  }
  </code></pre>
  
  <p>The problem is that the app I have setup inside my container is configured in such a way that it must run as it's own user, running as root will cause the application to fail on startup. If I change my args to <code>args '-u foo'</code>, I get errors after the container is built:</p>
  
  <p><code>/var/lib/jenkins/workspace/*/*/jenkins-log.txt permission denied</code></p>
  
  <p>This path is exists inside both the container and the jenkins server. I am having issues with the path inside the container. One of the files saved in that location is also a <code>scripts.sh</code> - jenkins transcribes all the sh commands in the pipeline to that file and runs that file.</p>
  
  <p>That puts me in a difficult spot - it seems as if Jenkins requires the container to be run as root to actually send any commands, or interact with anything inside the container, but the container will not build correctly unless I use <code>foo</code>.</p>
  
  <p>Does anyone have any ideas on a good solution for this problem?</p>