Unable to mount a file with docker-compose

两盒软妹~` 提交于 2019-12-14 02:12:21

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/52711305/unable-to-mount-a-file-with-docker-compose

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!