Suggest an editImprove this articleRefine the answer for “How to persist data between container runs? (junior)”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)To keep data from disappearing when a container is recreated, it is moved outside the container using **volumes** or **bind mounts**. **Key point:** to persist data between container runs, use a **volume or bind mount** - they move the data outside the container so it doesn't get lost.Shown above the full answer for quick recall.Answer (EN)ImageTo keep data from disappearing when a container is recreated, it is moved outside the container using **volumes** or **bind mounts**. ### **Two main approaches (junior)** #### **1. Docker volume (the best option for production)** ```bash docker volume create mydata docker run -v mydata:/app/data IMAGE ``` The data is stored outside the container, but managed by Docker. #### **2. Bind mount (mounting a host folder)** ```bash docker run -v /path/on/host:/app/data IMAGE ``` The data lives directly on the host, and the container simply uses it. ### **What this gives you** - data **doesn't disappear** on `docker stop`, `docker rm`, or when the image is rebuilt; - other containers can connect to it; - it's convenient for backups. ### **Summary** > To persist data between container runs, use a **volume or bind mount** - they move the data outside the container so it doesn't get lost. If needed, I can draw a simple diagram or show how to check a volume with `docker volume ls`.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.