title: Ignoring specific files in Dockerfile.dockerignore does not work
body: <p><strong>Here is my issue</strong>: I want to include/exclude specific file when building a service called <code>django</code>. But when playing with <code>Dockerfile.dockerignore</code> file, I do not succeed what I want and I can't figure out which syntax to adopt in order to do so.</p>
  <p><strong>Repo structure is the following</strong>:</p>
  <pre class="lang-sh prettyprint-override"><code>.
  └── root_dir
      ├── django
      │   ├── Dockerfile
      │   ├── Dockerfile.ignore
      │   └── stuff
      ├── documentation
      │   └── stuff
      ├── useless dir
      └── another useless dir
  </code></pre>
  <p>My <code>docker-compose.yml</code> used to make the build is the following:</p>
  <pre class="lang-yaml prettyprint-override"><code>version: '3.5'
  
  services:
  
    [...]
  
    django:
      build:
        context: $ROOT_DIR
        dockerfile: $ROOT_DIR/django/Dockerfile
  
    [...]
  </code></pre>
  <p>As you can see, context is <code>root_dir</code> and not <code>django</code> (because I need to copy a few things from <code>documentation</code> dir at build time).</p>
  <p><strong>What I need when building my image</strong>:</p>
  <ul>
  <li>django rep</li>
  <li>documentation rep</li>
  </ul>
  <p><strong>What I want to ignore when building my image</strong>:</p>
  <ul>
  <li>everything but <code>django</code> and <code>documentation</code> dirs</li>
  <li>Dockerfile and Dockerfile.dockerignore</li>
  <li>and a few other things (virtual env, <code>*.pyc</code> etc, but we'll stick with <code>Dockerfile</code> and <code>Dockerfile.dockerignore</code> for that question!)</li>
  </ul>
  <p>What my <code>Dockerfile.dockerignore</code> looks like in order to do so:</p>
  <pre class="lang-yaml prettyprint-override"><code># Ignore everything
  *
  
  # Allows django and documentation rep (context is root of project)
  !/django
  !/documentation
  
  # Ignoring some files
  **/Dockerfile
  **/Dockerfile.dockerignore
  </code></pre>
  <p>but my issue is that the files I want to ignore are still present in my image! And this is not good for me. I think I tried any syntax possible (<code>**/</code>, <code>*/*/...</code>...) but I can't find one that suits my need.</p>
  <p>Many thanks if you can help me with that!</p>
  <p>EDIT: for those wondering about that <code>Dockerfile.dockerignore</code> file, you can have a look here: <a href="https://docs.docker.com/engine/reference/commandline/build/#use-a-dockerignore-file" rel="nofollow noreferrer">https://docs.docker.com/engine/reference/commandline/build/#use-a-dockerignore-file</a></p>