Reputation: 8958
I run docker-compose -f docker-compose.prod.yml up
and I immediately get the error:
ERROR: for frontend Cannot start service frontend: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \"rootfs_linux.go:58: mounting \\\"/c/Users/James/Projects/mysite/frontend/conf/nginx/mysite.template\\\" to rootfs \\\"/var/lib/docker/aufs/mnt/e7a2a699ae3e9ede0dd60b7cfdebb7f2d3adf71e8175157f3c9e88d3285796d2\\\" at \\\"/var/lib/docker/aufs/mnt/e7a2a699ae3e9ede0dd60b7cfdebb7f2d3adf71e8175157f3c9e88d3285796d2/etc/nginx/conf.d/default.conf\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
My mysite.template
file exists. I am using digital ocean with docker-machine
. In development I didn't have this issue running on the same OS (ubuntu 16). I use docker toolbox on windows for development.
Here's the frontend config from docker-compose.prod.yml
:
frontend:
image: nginx:stable-alpine
restart: always
networks:
- web
- default
volumes:
- ${PWD}/frontend/conf/nginx/mysite.template:/etc/nginx/conf.d/default.conf
- ${PWD}/frontend/public:/var/www/html
labels:
- "traefik.enable=true"
- "traefik.basic.frontend.rule=Host:mysite.com"
- "traefik.basic.port=80"
I followed the instructions from the docs. Any ideas what's going wrong?
Upvotes: 3
Views: 15204
Reputation: 9634
You can only mount host directories as volumes, and not individual files in Docker.
In your volumes
definition, instead of this:
- ${PWD}/frontend/conf/nginx/mysite.template:/etc/nginx/conf.d/default.conf
you should do this:
- ${PWD}/frontend/conf/nginx:/etc/nginx/conf.d
Upvotes: 11