title: Keep Redis data alive between docker-compose down and up in Docker container
body: <p>Question is about keeping <code>Redis</code> data alive between <code>docker-compose up</code>  and <code>docker-compose down.</code></p>
  <p>In the <code>docker-compose.yaml</code> file bellow <code>db</code> service uses      - <code>postgres_data:/var/lib/postgresql/data/</code> volume to keep data alive.
  I would like to do something like this for <code>redis</code> service but I can not find workable solution to do so. Only one way I have managed to achieve this goal is to store data in local storage  <code>- ./storage/redis/data:/data.</code> All experiments with external volume gave no results.</p>
  <p>Question is  -is it possible somehow to store redis data between <code>docker-compose down</code> and <code>docker-compose up</code> in a volume likewise  it made in <code>DB</code> service?</p>
  <p>Sorry if question is naive…</p>
  <p>Thanks</p>
  <pre><code>version: '3.8'
  
  services:
    web:
      build: .
      command: python /code/manage.py runserver 0.0.0.0:8000
      env_file:
        - ./series/.env
      volumes:
        - .:/code
      ports:
        - 8000:8000
      depends_on:
        - db
        - redis
  
    db:
      build:
        context: .
        dockerfile: postgres.dockerfile
      restart: always
      env_file:
        - ./series/.env
      environment:
        - POSTGRES_DB=postgres
        - POSTGRES_USER=postgres
        - POSTGRES_PASSWORD=1q2w3e
      volumes:
        - postgres_data:/var/lib/postgresql/data/
      ports:
        - target: 5432
          published: 5433
          protocol: tcp
          mode: host
  
    redis:
      image: redis:alpine
      command: redis-server --appendonly yes
      ports:
        - target: 6379
          published: 6380
          protocol: tcp
          mode: host
      volumes:
          - ./storage/redis/data:/data
      restart: always
      environment:
        - REDIS_REPLICATION_MODE=master
  
  volumes:
      postgres_data:
  
  
  
  
  </code></pre>