Task: it is necessary when saving a container to save files from an image to a host, provided that the folder to be mounted is empty. For example, the mongodb image (from the documentation) also works.
docker run --name some-mongo -v /my/own/datadir:/data/db -d mongo
I tested this construction (I work from under Windows), it works fine, the database is saved on the host machine. Making attempts on my image to turn a similar scheme, I get an empty folder in the container, the data from the image completely overlap. I did various tests with Dockerfile and VOLUME, the result is always the same. Dockerfile example:
FROM ubuntu RUN mkdir /myfolder RUN echo "hello world" > /myfolder/greeting VOLUME /myfolder
I build an image, I launch the container, waiting to get the contents of the folder /myfolder in D:/Docker/, but there is no file.
docker run -it -v D:/Docker:/myfolder -d app
Folder is empty ...