title: Jenkins Docker Declarative .withRun
body: <p>I am using the declarative format for pipeline files and running inside of a docker container that is defined using a Dockerfile in my project's root directory. </p>
  
  <p>My Jenkinsfile looks like this:</p>
  
  <pre><code>pipeline {
    agent {
      dockerfile {
        additionalBuildArgs '--network host'
      }
    }
    stages {
      stage('Test') {
        steps {
          sh 'pytest --version'
        }
      }
  }
  </code></pre>
  
  <p>I would like to pass additional arguments to the docker run command similar to this question ... <a href="https://stackoverflow.com/questions/46206215/how-to-pass-docker-container-arguments-when-running-the-image-in-a-jenkinsfile">How to pass docker container arguments when running the image in a Jenkinsfile</a></p>
  
  <p>Is it possible to do that in the declarative pipeline format, or should I switch?</p>
  
  <p>Edit: </p>
  
  <p>This is essentially the equivalent of what I am trying to do in non-declarative:</p>
  
  <pre><code>node {
    def pytestImage = docker.build('pytest-image:latest', '--network host .')
  
    pytestImage.inside('--network=host') {
      sh 'pytest --version'
      // other commands ...
    }
  }
  </code></pre>