About docker persistence

Hi folks,

I’m totally new to docker and after a few tries data persistence is unclear to me.
If I pull an image, apache for example, run and connect to it I’m landing in /var/www/html.
Now I’m creating a file and stop the container. After restarting the previous created file is still there, despite in every documentation I read after restarting an container it’s data will be lost. ( so therefore persistent volume container were developed, isn’t it?)
Can anyone help me to understand this fact.

containers will keep their data if you just stop and restart them.
containers just instantiate an docker image and add an overlay with your changes on top of it.
but if you do another docker run YOUR_IMAGE to create a new container from your image, then your changes will not be there.
if you want to persist your data also over docker recreation, you could look into docker volumes.