Docker documentation says that it\'s possible to mount a single file into a Docker container:
The -v flag can also be used to mount a single file - in
test is the name of your image that you have built with 'docker build -t test', not a /test folder.
Try a Dockerfile with:
CMD ["ls", "-lah", "/"]
or
CMD ["cat", "/file.json"]
And:
docker run --rm -it -v $(pwd)/file.json:/file.json test
Note the use of $(pwd) in order to mount a file with its full absolute path (relative paths are not supported)
By using $(pwd), you will get an absolute path which does exists, and respect the case, as opposed to a file name or path which might not exist.
An non-existing host path would be mounted as a folder in the container.