Docker containers do persist after exits, unless the
command used the
option. So if you exit the shell, then restart and re-attach to that container the earlier files are still there. However, Docker management best practices are to consider containers as read-only and generate new images with a Dockerfile and the
command. While you are in a container, you can use the
command, which will save the container contents to a new image, it's just not recommended to use that as a way of "saving" your container.
There are ways to reduce docker image sizes, such as using a smaller base image, minimize layers, using the
option when running the
command. Docker has a lot of flexibility, but it's also a new way of thinking about computing so using it like a standard storage device can get you in trouble. Some best practices models for Docker have the data kept externally to the container, like with host volume mounts. There's a cool wiki that has all sorts of information about containers, and it has resources on how to create docker images if you are interested, the Container Technology Wiki
Apologies, I'm not sure why that "Code, Select All" weird formatting is in there. Sorry. I'm a noob.