title: .dockerignore fails to include files in subdirectories with !**/*.extension pattern
body: <p>I'm having trouble with the <code>.dockerignore</code> file. This is my project structure:</p>
  
  <pre><code>file.sh
  file.js
  file.go
  file.py
  subdir/
      file2.go
      file2.py
  .dockerignore
  Dockerfile
  </code></pre>
  
  <p>According to the <a href="https://docs.docker.com/engine/reference/builder/#dockerignore-file" rel="noreferrer"><code>.dockerignore</code> documentation</a>:</p>
  
  <blockquote>
    <p>(...) you may want to specify which files to include in the context, rather than which to exclude. To achieve this, specify * as the first pattern, followed by one or more ! exception patterns.</p>
  </blockquote>
  
  <p>And:</p>
  
  <blockquote>
    <p>Lines starting with ! (exclamation mark) can be used to make exceptions to exclusions.</p>
  </blockquote>
  
  <p>Finally:</p>
  
  <blockquote>
    <p>Docker also supports a special wildcard string ** that matches any number of directories (including zero). For example, **/*.go will exclude all files that end with .go that are found in all directories, including the root of the build context.</p>
  </blockquote>
  
  <p>Based on that, this is my <code>.dockerignore</code> file:</p>
  
  <pre><code># ignore everything
  *
  
  # whitelist
  # ---------
  
  # python files
  !**/*.py
  </code></pre>
  
  <p>When I build and run the container and inspect the files, I get this:</p>
  
  <pre><code>file.py
  </code></pre>
  
  <p>The <code>subdir</code> directory is missing, <code>subdir/file2.py</code>should be included. It works if I add <code>!subdir/**/.py</code> to my <code>.dockerignore</code>, but the idea is to include any <code>.py</code> file in any subdirectory.</p>
  
  <p>This is the file structure that should be present in the container:</p>
  
  <pre><code>file.py
  subdir/
      file2.py
  </code></pre>
  
  <p>What's going on here?</p>