title: How to clear cache for Django with Docker?
body: <p>I have a Django project that I am using with memcached and Docker. When I use <code>sudo docker-compose up</code> in development I'd like the entire cache to be cleared. Rather than disabling caching wholesale while in development mode, is there a way to run <code>cache.clear()</code> as noted in <a href="https://stackoverflow.com/questions/6159841/how-to-clear-the-whole-cache-when-using-djangos-page-cache-decorator">this question</a> on each re-run of <code>sudo docker-compose up</code>? </p>
  
  <p>I am not sure whether this should go in:</p>
  
  <ol>
  <li><code>docker-entrypoint.sh</code></li>
  <li><code>Dockerfile</code></li>
  <li><code>docker-compose.yml</code></li>
  <li>Somewhere else?</li>
  </ol>
  
  <h3>docker-compose.yml:</h3>
  
  <pre><code>version: "3"
  services:
    redis:
      image: "redis:alpine"
      command: "redis-server --requirepass ${REDISPASS} --bind 0.0.0.0"
      ports:
        - '6379:6379'
    memcached:
      image: "memcached:latest"
      ports:
        - '11211:11211'
    nginx:
        image: nginx:latest
        volumes:
          - ./configuration/nginx/conf.d/:/etc/nginx/conf.d
          - ./configuration/nginx/realtime:/etc/nginx/realtime
          - ./static_cdn/static_root/static:/static
        ports:
          - 80:80
          - 443:443      
        depends_on:
          - app_main
          - app_async_app1
          - app_async_app2
    app_main:
        command: "djangoAppName.settings.prod ${SECRET_KEY} 1 ${DB_PASS}     ${REDISPASS}"      
        image: "django_image_name"
        ports:
          - 0003:0003
        volumes:
          - ./static_cdn/static_root/:/static_cdn/
        depends_on:
          - redis
          - memcached
   app_async_app2:
        command: "djangoAppName.settings.prod ${SECRET_KEY} 2 ${DB_PASS} ${REDISPASS}"      
        image: "django_image_name"
        ports:
          - 0002:0002
        depends_on:
          - redis
          - memcached
          - app_main
    app_async_app1:
        command: "djangoAppName.settings.prod ${SECRET_KEY} 3 ${DB_PASS} ${REDISPASS}"    
        image: "django_image_name"
        depends_on:
          - redis
          - memcached
          - app_main
        ports:
          - 0001:0001
    react:
        command: "npm run"
        image: "django_image_name"
        volumes:
          - ./static_cdn/static_root/:/static_cdn/
        depends_on:
          - memcached
          - app_main
  </code></pre>