On Docker for Mac when i do
~/tmp> echo “hello world” > test.txt
docker run -v ~/tmp/test.txt:/test/test.txt alpine cat /test/test.txt
I’ve got:
hello world
as result
Actual behaviour
On Docker for Windows when i do:
echo “Hello world” > test.txt
docker run -v /C/Users/survdemo/test.txt:/test/test.txt alpine cat /test/test.txt
I’ve got:
cat: read error: Is a directory
so /test/test.txt is a directory.
Information
Client:
Version: 1.12.0
API version: 1.24
Go version: go1.6.3
Git commit: 8eab29e
Built: Thu Jul 28 21:15:28 2016
OS/Arch: windows/amd64
Server:
Version: 1.12.0
API version: 1.24
Go version: go1.6.3
Git commit: 8eab29e
Built: Thu Jul 28 21:15:28 2016
OS/Arch: linux/amd64
Do anybody can help me with this different behaviour Mac and Windows?
You do not have to mount a directory. I mount files all the time and it works just fine. The problem is that you are using a relative path. Try using a full path instead.
It’s a quite old issue, but one of my colleagues faced the same problem today.
On Windows, antivirus and similar softwares might prevent docker to access the file system, leading docker to the creation of an empty folder rather then mounting the specified file.
Hopefully this solves for you as well.
The latest update caused this for me.
I ended up going semi-nuclear, deleting all my images and containers and then docker-compose up.
Stop all containers
docker stop $(docker ps -a -q)
Delete all containers
docker rm $(docker ps -a -q)
Delete all images
docker rmi $(docker images -q)
I had this same issue - previously I could mount files, then it started mounting all files and folders. Turned out I had to go to settings > Shared Drives, Reset credentials, and then share the volumes again.