title: Jenkins/Docker: How to force pull base image before build
body: <p>Docker allows passing the <code>--pull</code> flag to <code>docker build</code>, e.g. <code>docker build --pull -t myimage .</code>. How can I enforce pulling the base image with a pipeline script in my <code>Jenkinsfile</code>? This way I want to ensure that the build always uses the latest container image despite of the version available locally.</p>
  
  <pre><code>node('docker') {
      def app
  
      stage('Checkout') {
          checkout scm
      }
  
      stage('Build image') {
          docker.withRegistry('https://myregistry.company.com', 'dcr-jenkins') {
              app = docker.build "myimage"
          }
      }
  
      stage('Publish image') {
          docker.withRegistry('https://myregistry.company.com', 'dcr-jenkins') {
              app.push("latest")
          }
      }
  }
  </code></pre>