Compose: "[8] System error: not a directory" when trying to mount file

Created on 28 Oct 2015  路  9Comments  路  Source: docker/compose

I am trying to mount a file into a container but i am getting error ""

Following is my docker-compose.yml

nginx:
  image: nginx
  ports:
    - "80:80"
  volumes:
    - ./nginx/nginx.conf:/etc/nginx/nginx.conf

As per following discussion https://github.com/docker/docker/issues/13276 have moved everything in c:/Users/${userid} folder. Also to share i am using rancheros instead of standard boot2docker.

Client:
 Version:      1.8.2
 API version:  1.20
 Go version:   go1.4.2
 Git commit:   0a8c2e3
 Built:        Thu Sep 10 19:10:10 UTC 2015
 OS/Arch:      windows/amd64

Server:
 Version:      1.9.0-rc2
 API version:  1.21
 Go version:   go1.4.3
 Git commit:   60d36f7
 Built:        Fri Oct 23 00:20:59 UTC 2015
 OS/Arch:      linux/amd64
kinquestion

Most helpful comment

It used to give me the same error when I wanted to share a file, but in the container exists a directory with the same name. Just deleting the dir my problem was solved.

All 9 comments

You can use docker inspect <container name> to see the path it's trying to mount. Then make sure the file exist as that path on the host

Using Docker Machine on Windows 8 created rancheros Docker host; just in case if it helps us debug this issue. Following is the output of docker inspect.

"Mounts": [
    {
        "Source": "/C/Users/divyjain/app/virtualized-runner/config/config.xml",
        "Destination": "/app/config/config.xml",
        "Mode": "rw",
        "RW": true
    }]

When i ssh into docker host using "docker-machine ssh default" i can see /C/Users/divyjain/app/virtualized-runner/config/config.xml as directory and not as a file.

Not sure why this is created as a directory instead of file.

If the host part of a volume doesn't exist then docker creates it, I think that's why it's a directory. In compose 1.5.0rc1 we had a bug where the uppercase letter C' was being used for the driver, but linux is case sensitive, so it needs to be the lowercasec`.

We fixed that in rc2. Can you try with docker-compose 1.5.0rc2 ?

It should be working now.

it works after upgrading to rc3

It used to give me the same error when I wanted to share a file, but in the container exists a directory with the same name. Just deleting the dir my problem was solved.

Hello!
I have a similar problem.
I use the docker-compose for Windows and I have a problem with mounting the file:

volumes:
聽聽聽聽聽聽 - ./nginx.conf:/etc/nginx/nginx.conf

if the file is located in any folder inside C:Users\ ... works well, but if in a different folder, for example C:\Dev** - I have error
**\\" caused \\"not a directory\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)?

@KondratenkoAndrey I think by default, only the Users directory is shared between the host and the Linux VM in which the daemon runs. Any other location therefore won't exist inside the Linux VM, which will result in docker creating a directory at that location, and bind-mount it inside the container.

I'm not running Docker on Windows myself, but this section in the documentation describes how to configure shared locations; https://docs.docker.com/docker-for-windows/#shared-drives

@KondratenkoAndrey I think by default, only the Users directory is shared between the host and the Linux VM in which the daemon runs. Any other location therefore won't exist inside the Linux VM, which will result in docker creating a directory at that location, and bind-mount it inside the container.

I'm not running Docker on Windows myself, but this section in the documentation describes how to configure shared locations; https://docs.docker.com/docker-for-windows/#shared-drives

Thank you!
Really, only Users directory is shared for the virtual machine.
I added the C:\Dev folder to shared:

image

however this did not solve the problem, I get the same error.
Any other ideas?

@KondratenkoAndrey I think by default, only the Users directory is shared between the host and the Linux VM in which the daemon runs. Any other location therefore won't exist inside the Linux VM, which will result in docker creating a directory at that location, and bind-mount it inside the container.
I'm not running Docker on Windows myself, but this section in the documentation describes how to configure shared locations; https://docs.docker.com/docker-for-windows/#shared-drives

Thank you!
Really, only Users directory is shared for the virtual machine.
I added the C:\Dev folder to shared:

image

however this did not solve the problem, I get the same error.
Any other ideas?

I solved the problem!
You were right!
Additionally the name should be in this format:

image

Thank you!

Was this page helpful?
0 / 5 - 0 ratings