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
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.
@settermjd https://github.com/moby/moby/issues/27010#issuecomment-250437911
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.
volume part from the docker-compose.yaml filedocker-compose up -d commandvolume part into the docker-compose.yaml filedocker-compose up -dcommand againI 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.