title: Why isn't my .Dockerignore file ignoring files?
body: <p>When I build the container and I check the files that should have been ignored, most of them haven't been ignored.</p>
  <p><strong>This is my folder structure</strong>.</p>
  <pre><code>Root/
  
    data/
  
    project/
      __pycache__/
      media/
      static/
  
    app/
      __pycache__/
      migrations/
      templates/
  
    .dockerignore
    .gitignore
    .env
    docker-compose.yml
    Dockerfile
    requirements.txt
    manage.py
  </code></pre>
  <p>Let's say i want to ignore the <code>__pycache__</code> &amp; <code>data</code>(data will be created with the <code>docker-compose up</code> command, when creating the container) folders and the <code>.gitignore</code> &amp; <code>.env</code> files.</p>
  <p>I will ignore these with the next <strong>.dockerignore</strong> file</p>
  <pre><code>.git
  .gitignore
  
  .docker
  
  */__pycache__/
  **/__pycache__/
  
  .env/
  .venv/
  venv/
  
  data/
  </code></pre>
  <p>The final result is that only the <code>git</code> &amp; <code>.env</code> files have been ignored. The data folder hasn't been ignored but it's not accesible from the container. And the <code>__pycache__</code> folders haven't been ignored either.</p>
  <p>Here are the docker files.</p>
  <p><strong>docker-compose.yml</strong></p>
  <pre><code>version: &quot;3.8&quot;
  
  services: 
  
    app: 
      build: .
      volumes: 
        - .:/django-app
      ports: 
        - 8000:8000
      command: /bin/bash -c &quot;sleep 7; python manage.py migrate; python manage.py runserver 0.0.0.0:8000&quot;
      container_name: app-container
      depends_on: 
        - db
  
    db:
      image: postgres
      volumes:
        - ./data:/var/lib/postgresql/data
      environment: 
        - POSTGRES_DB=${DB_NAME}
        - POSTGRES_USER=${DB_USER}
        - POSTGRES_PASSWORD=${DB_PASSWORD}
      container_name: postgres_db_container
  </code></pre>
  <p><strong>Dockerfile</strong></p>
  <pre><code>FROM python:3.9-slim-buster
  
  ENV PYTHONUNBUFFERED=1
  
  WORKDIR /django-app
  EXPOSE 8000
  
  COPY requirements.txt requirements.txt
  
  RUN apt-get update \
      &amp;&amp; adduser --disabled-password --no-create-home userapp \
      &amp;&amp; apt-get -y install libpq-dev \
      &amp;&amp; apt-get -y install apt-file \
      &amp;&amp; apt-get -y install python3-dev build-essential \
      &amp;&amp; pip install -r requirements.txt
  
  USER userapp
  </code></pre>