title: Using Docker for Windows in Jenkins Declarative Pipeline
body: <p>I am setting up a CI workflow with Jenkins declarative pipeline and Docker-for-Windows agents through <code>Dockerfile</code>. </p>
  
  <p><em>Note: It is unfortunately currently not a solution to use a Linux-based docker daemon, since I need to run Windows binaries.</em></p>
  
  <p><strong>Setup:</strong> Jenkins master runs on Linux 16.04 through Docker. Jenkins build agent is </p>
  
  <ul>
  <li>Windows 10 Enterprise 1709 (16299.551)</li>
  <li>Docker-for-Windows 17.12.0-ce</li>
  </ul>
  
  <p>Docker 18.x gave me headaches when trying to use Windows Containers, so I rolled back to 17.x. I still had some issues when trying to run with Jenkins and nohup not being on path, but it was solved by <a href="https://issues.jenkins-ci.org/browse/JENKINS-33708?focusedCommentId=285730&amp;page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-285730" rel="nofollow noreferrer">adding Git binaries to Windows search path</a> (<a href="https://stackoverflow.com/questions/49305031/jenkins-with-docker-on-windows-cannot-run-program-nohup?noredirect=1&amp;lq=1">another reference</a>). I suspect my current issue may be related.</p>
  
  <p><strong>Code:</strong> I am trying to initialize a <code>Jenkinsfile</code> and run a simple hello-world-printout within.</p>
  
  <p>/Jenkinsfile</p>
  
  <pre><code>pipeline {
    agent none
    stages {
      stage('Docker Test') {
        agent {
          dockerfile {
            filename 'Dockerfile'
            label 'windocker'
          }
        }
        steps {
          println 'Hello, World!'
        }
      }
    }
  }
  </code></pre>
  
  <p>/Dockerfile</p>
  
  <pre><code>FROM python:3.7-windowsservercore
  RUN python -m pip install --upgrade pip
  </code></pre>
  
  <p>Basically, this should be a clean image that simply prints "Hello, World!". <strong>But it fails on Jenkins!</strong></p>
  
  <p>Output from the log:</p>
  
  <pre><code>[C:\jenkins\workspace\dockerfilecd4c215a] Running shell script
  + docker build -t cbe5e0bb1fa45f7ec37a2b15566f84aa9bd08f5d -f Dockerfile .
  Sending build context to Docker daemon  337.4kB
  
  Step 1/2 : FROM python:3.7-windowsservercore
   ---&gt; 340689b75c39
  Step 2/2 : RUN python -m pip install --upgrade pip
   ---&gt; Using cache
   ---&gt; a93f446a877f
  Successfully built a93f446a877f
  Successfully tagged cbe5e0bb1fa45f7ec37a2b15566f84aa9bd08f5d:latest
  [C:\jenkins\workspace\dockerfilecd4c215a] Running shell script
  + docker inspect -f . cbe5e0bb1fa45f7ec37a2b15566f84aa9bd08f5d
  .
  Cannot run program "id": CreateProcess error=2, The system cannot find the file specified
  </code></pre>