title: Docker compose using parts of old images
body: <p>I have a compose file as follows:</p>
  <pre><code>version: &quot;3&quot;
  services:
  
    oj-redis:
      image: redis:4.0-alpine
      container_name: oj-redis
      restart: always
      volumes:
        - ./data/redis:/data
    
    oj-postgres:
      image: postgres:10-alpine
      container_name: oj-postgres
      restart: always
      volumes:
        - ./data/postgres:/var/lib/postgresql/data
      environment:
        - POSTGRES_DB=onlinejudge
        - POSTGRES_USER=onlinejudge
        - POSTGRES_PASSWORD=onlinejudge
  
    judge-server:
      image: &lt;image-name&gt;
      container_name: judge-server
      restart: always
      read_only: true
      cap_drop:
        - SETPCAP
        - MKNOD
        - NET_BIND_SERVICE
        - SYS_CHROOT
        - SETFCAP
        - FSETID
      tmpfs:
        - /tmp
      volumes:
        - ./data/backend/test_case:/test_case:ro
        - ./data/judge_server/log:/log
        - ./data/judge_server/run:/judger
      environment:
        - SERVICE_URL=http://judge-server:8080
        - BACKEND_URL=http://oj-backend:8000/api/judge_server_heartbeat/
        - TOKEN=CHANGE_THIS
        # - judger_debug=1
    
    oj-backend:
      image: &lt;image-name&gt;
      container_name: oj-backend 
      restart: always
      depends_on:
        - oj-redis
        - oj-postgres
        - judge-server
      volumes:
        - ./data/backend:/data
      environment:
        - POSTGRES_DB=onlinejudge
        - POSTGRES_USER=onlinejudge
        - POSTGRES_PASSWORD=onlinejudge
        - JUDGE_SERVER_TOKEN=CHANGE_THIS
        - PROCTOR_URL=http://localhost:3000
        # - FORCE_HTTPS=1
        # - STATIC_CDN_HOST=cdn.oj.com
      ports:
        - &quot;0.0.0.0:80:8000&quot;
        - &quot;0.0.0.0:443:1443&quot;
  </code></pre>
  <p>Whenever I build a new image on docker hub and pull it with <code>docker-compose up -d</code> some parts of my <code>oj-backend</code> container get updated while others do not. When I access some API's they return data from the old build. The only solution I found was to <code>rm -rf</code> the volume directory <code>data</code> and run <code>docker-compose up</code> again.</p>
  <p>I inspected the container and all the files are updated so I'm not sure how this is happening.</p>
  <p>I need the data from the mounted directory in production so I can't delete it and restart from scratch.</p>
  <p>Here is the dockerfile of <code>oj-backend</code></p>
  <pre><code>FROM python:3.7-alpine3.9
  
  ENV OJ_ENV production
  
  ADD . /app
  WORKDIR /app
  
  HEALTHCHECK --interval=5s --retries=3 CMD python2 /app/deploy/health_check.py
  
  RUN apk add --update --no-cache build-base nginx openssl curl unzip supervisor libffi-dev jpeg-dev zlib-dev postgresql-dev freetype-dev &amp;&amp; \
      pip install --no-cache-dir -r /app/deploy/requirements.txt &amp;&amp; \
      apk del build-base --purge
  
  RUN curl -L  $(curl -s  https://api.github.com/repos/steviekong/OnlineJudgeFE/releases/tags/oj_2.7.0-beta.2 | grep /dist.zip | cut -d '&quot;' -f 4) -o dist.zip &amp;&amp; \
      unzip dist.zip &amp;&amp; \
      rm dist.zip
  
  ENTRYPOINT /app/deploy/entrypoint.sh
  </code></pre>
  <p>It is a django server.</p>