# Docker: Redis data gone after container restart — dump.rdb not persisted to a volume

**Code:** `Redis in Docker loses data on restart (no volume)` · **Category:** Redis · **Seen on:** Redis, Docker

The container's `/data` isn't mounted to a volume, so snapshots vanish when the container is recreated.

## Meaning

Mount a volume at `/data` (`-v redis-data:/data` or compose `volumes`), enable persistence (`--save 60 1` / `--appendonly yes`), and make sure the container user can write to it. `docker compose down -v` deletes the volume. For caches only, no persistence is fine.

## Common causes

- No volume mounted for /data
- Persistence disabled (`save ""`)
- `docker compose down -v` removing volumes
- Permission issues on bind mounts
- Different image/data path

## Quick fix

1. `volumes: - redis-data:/data` and `command: redis-server --appendonly yes`
2. Avoid `down -v` unless intended
3. Check `docker exec redis ls -l /data`

## Detailed fix by platform

### Docker

1. `docker run -d --name redis -v redis-data:/data redis:7 redis-server --appendonly yes`

## How to diagnose

1. **Volume** — Mounted at /data?
2. **Persistence** — save/appendonly?
3. **Cleanup** — down -v?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/redis/redis-docker-data-not-persisted-volume)
