If you do not want to use volumes, you can save your container at a specific time by using docker commit --change "added some changes to my container" <container_id> repo/image:tag
The new image will contains all filesystem of your current container.
That being said, not using volume has several disadvantages:
By default all files created inside a container are stored on a writable container layer. This means that:
The data doesn’t persist when that container is no longer running, and it can be difficult to get the data out of the container if another process needs it.
A container’s writable layer is tightly coupled to the host machine where the container is running. You can’t easily move the data somewhere else.
Writing into a container’s writable layer requires a storage driver to manage the filesystem. The storage driver provides a union filesystem, using the Linux kernel. This extra abstraction reduces performance as compared to using data volumes, which write directly to the host filesystem.
So your best choice is to use volume !
Now you can choose between different kinds:
- bind mounts
- named volumes
While bind mounts are dependent on the directory structure of the host machine, volumes are completely managed by Docker. Volumes have several advantages over bind mounts:
Volumes are easier to back up or migrate than bind mounts.
You can manage volumes using Docker CLI commands or the Docker API.
Volumes work on both Linux and Windows containers.
Volumes can be more safely shared among multiple containers.
Volume drivers let you store volumes on remote hosts or cloud providers, to encrypt the contents of volumes, or to add other functionality.
New volumes can have their content pre-populated by a container.
Read the documentation to understand volume's features better : https://docs.docker.com/storage/volumes/