Compose: caused "not a directory"

Created on 24 Sep 2016  路  9Comments  路  Source: docker/compose

I cannot mount the nginx config file:

version: '2'
services:
    web:
        image: nginx:latest
        ports:
            - "8080:80"
        volumes:
            - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf

Error:

$ docker-compose up
Creating network "docker_default" with the default driver
Creating docker_web_1

ERROR: for web  Cannot start service web: oci runtime error: rootfs_linux.go:53: mounting "/mnt/sda1/var/lib/docker/aufs/mnt/9ef61a113b176b7175ed0f870828b29664300ac9a5dea57fe1987dfa308633be/etc/nginx/conf.d/default.conf" to rootfs "/mnt/sda1/var/lib/docker/aufs/mnt/9ef61a113b176b7175ed0f870828b29664300ac9a5dea57fe1987dfa308633be" caused "not a directory"
ERROR: Encountered errors while bringing up the project.

Via docker:

$ docker run --rm -it -v $(pwd)/nginx/nginx.conf:/etc/nginx/conf.d/default.conf nginx:latest
docker: Error response from daemon: oci runtime error: rootfs_linux.go:53: mounting "/mnt/sda1/var/lib/docker/aufs/mnt/1d488c9f67c62b352ba91ca537bd72666b1b635d88e112a3ad4bf3cc63600a8a/etc/nginx/conf.d/default.conf" to rootfs "/mnt/sda1/var/lib/docker/aufs/mnt/1d488c9f67c62b352ba91ca537bd72666b1b635d88e112a3ad4bf3cc63600a8a" caused "not a directory".

OS: OSX 10.9.5
Docker:

$ docker --version
Docker version 1.12.0, build 8eab29e

$ docker-machine --version
docker-machine version 0.8.0, build b85aac1

$ docker-compose --version
docker-compose version 1.8.0, build f3628c7
kinquestion

All 9 comments

I encountered the same problem. Ensure that '/etc/nginx/conf.d/default.conf' exists on your host.

@miguelcudaihl /etc/nginx/conf.d/default.conf exists on my host:

docker-compose.yml:

version: "2"
services:
    web:
        image: nginx:latest
        ports:
            - "8080:80"
        command: ls -l /etc/nginx/conf.d

Out:

$ docker-compose up
Recreating docker_web_1
Attaching to docker_web_1
web_1  | total 4
web_1  | -rw-r--r-- 1 root root 1097 Sep 13 16:18 default.conf
docker_web_1 exited with code 0

Hi!

First off, if docker run gives you the exact same error message, chances are it's not actually a Compose error and thus should not be reported here.

Now to answer your question, you can only mount directories using volume bindings - not single files.

HTH!

you can only mount directories using volume bindings - not single files

Due to limitations of docker or compose? According to the docker docs it is possible. I can't find this information in compose docs, but it was always possible - has something changed lately here? Can't find information in the changelog neither.

Oops - I don't know what I was thinking. You're right, that is possible.

My other point still stands however - since the behavior is identical with docker run, this is a bug in engine and should be reported there.

I'm pretty new to Docker (at least deploying with it), but I can both ls and cat default.conf, yet I get this error.

I had the same issue because I did not create the file on the host before running the docker-compose command, so the docker-compose command automatically created a folder which makes sense.

When I deleted the folder and created the file at the same location, that error popped up, I'm suspecting there's some cache that tagged that volume as a folder.

To solve the issue I removed the volume part from the docker-compose.yml, ran the docker-compose command again, then I put back the volume part back to the file and it worked.

TL;DR

  1. Remove the volume part from the docker-compose.yaml file
  2. Run your docker-compose up -d command
  3. Put back the volume part into the docker-compose.yaml file
  4. Run your docker-compose up -dcommand again

I solved this by removing the volumes from docker. Using docker volume ls will show all volumes, you can then remove the specific volume using:

docker volume rm <volume_name_here>

Rebuilding the container will create a new copy of the volume.

Was this page helpful?
0 / 5 - 0 ratings