title: Unable to change a directory inside a Docker container through a Jenkins declarative pipeline
body: <p>I'm trying to change the current directory using the <code>dir</code> command outlined here: <a href="https://jenkins.io/doc/pipeline/steps/workflow-basic-steps/#code-dir-code-change-current-directory" rel="nofollow noreferrer">https://jenkins.io/doc/pipeline/steps/workflow-basic-steps/#code-dir-code-change-current-directory</a></p>
  
  <p>I've edited my pipeline to resemble something like this:</p>
  
  <pre><code>pipeline {
      agent { dockerfile true } 
      stages { 
          stage('Change working directory...') { 
              steps {
                  dir('/var/www/html/community-edition') {
                      sh 'pwd'
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>It doesn't change the directory at all but instead tries to create a directory on the host and fails with <code>java.io.IOException: Failed to mkdirs: /var/www/html/community-edition</code></p>
  
  <p>Using <code>sh cd /var/www/html/community-edition</code> doesn't seem to work either. How do I change the directory in the container? Someone else seems to have had the same issue but had to change his pipeline structure to change the directory and doesn't sound like a reasonable fix. Isn't the step already being invoked in the container? <a href="https://issues.jenkins-ci.org/browse/JENKINS-46636" rel="nofollow noreferrer">https://issues.jenkins-ci.org/browse/JENKINS-46636</a></p>