Docker - Container Volumes
Each docker container has its own isolated volume. By default, this volume isn't persistent, meaning that if the container restarts or gets deleted, then so does its data.
To have persistent data on a container, you have to map a directory on the docker host, to a directory on the container.
docker run -v /path/on/host:/path/on/container containername
Example;
I have a MySQL container that I need to keep persistent data on. To do this, I would map the /var/lib/mysql directory on the container, to a location on the docker host.
docker run -v /opt/mysql_container_data:/var/lib/mysql mysql