When I went through the Docker Fundamental online training a while back, I remember a statement from the instructor “volume changes are excluded when updating an image”. that statement sounds confusing for me at the time as the primary reason for mapping volume was making data persistent independent of container running or not.
Now I realized that statement is actually incorrect. The reason the added file ‘test’ in the volume /www/website/ disappeared after a container was started from the committed images was while the base container was started with volume mapping, the new container was started without corresponding clause. In such a case, only the “mount point” created during initial volume mapping was committed in the new container image. They are actually not the same file system, of course the file created in the volume of base container is not there. But it is certainly there in the host folder /www/website/.
So the real matter should be “volume mapping doesn’t persist across containers images.” If you want the same volume, you have to map it explicitly when a container is first ‘run’.