The Docker documentation about bind mounts states that:
The file or directory does not need to exist on the Docker host already. It is created on demand if it does not yet exist.
This is true for folders: if I bind mount as:
docker run -v $PWD/mydir:/mydir image:version
then the mydir
folder is created and bind mounted in the container. But I cannot find the syntax for doing the same thing for a file either at the above linked page nor anywhere else.
Copyright Notice:Content Author:「Nicola Mori」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/72621218/create-and-bind-mount-file-in-docker