Docker Community Forums

Share and learn in the Docker community.

Are you able to mount a file volume with docker windows with Docker Run -d -v localfile:containerfile image

Does Docker Windows support a FILE volume mapping?

Example

docker run -d -v C:\directory\filename:/containerdir/filename imagename

I am able to get this working on a folder level.

docker run -v c:/configs:c:/app/config -d -p 9090:80 qaaauthservice
51bfc482d2acf6caf20356d4eec01c6f866a4f01ef8684793920c0e6c066ddf0

but on a file level it fails

docker run -v c:/configs/appsettings.QAA.json:c:/app/appsettings.json -d -p 9090:80 qaaauthservice

docker: Error response from daemon: invalid volume specification: ‘c:/configs/appsettings.QAA.json:c:/app/appsettings.json’: invalid mount config for type “bind”: source path must be a directory.

this is with the latest version of docker desktop for windows

Ok it looks like a file to file mapping is not supported in Docker Desktop for windows the docker forums on github. The folder to folder volume mapping is supported.

so this is supported where c:\configs is a folder on the windows host and /app/config is a folder on the container image

docker run -v c:/configs:c:/app/config -d -p 9090:80 qaaauthservice

this is NOT supported on windows docker

docker run -v c:/configs/appsettings.QAA.json:c:/app/config/appsettings.json -d -p 9090:80 qaaauthservice

Shame. Is this something that will be addressed in Docker Desktop for Windows?
That docker forums on github, do you have a link to it?
I could not find any open issue for this on GitHub - docker/for-win: Bug reports for Docker Desktop for Windows