Master data persistence in Docker using volumes, bind mounts, and tmpfs. Learn to manage stateful applications and share data between containers.
See how container data disappears when containers are removed.
docker run --name temp-container ubuntu bash -c 'echo "Important data" > /data.txt && cat /data.txt'docker start temp-containerdocker exec temp-container cat /data.txtdocker rm -f temp-containerdocker run --name temp-container ubuntu cat /data.txtContainer filesystems are ephemeral. Data created inside a container is lost when the container is removed. Each new container starts fresh from the image.
First container shows the data. After removal, new container with same name can't find /data.txt - the file is gone.