[英]Unable to mount a file with docker-compose
我運行docker-compose -f docker-compose.prod.yml up
並立即收到錯誤:
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
我的mysite.template
文件存在。 我在docker-machine
使用數字海洋。 在開發中,我沒有在同一OS(ubuntu 16)上運行此問題。 我在Windows上使用docker工具箱進行開發。
這是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"
我遵循了docs的指示。 任何想法出什么事了嗎?
您只能將主機目錄作為卷掛載,而不能將單個文件掛載在Docker中。
在volumes
定義中,而不是以下內容: - ${PWD}/frontend/conf/nginx/mysite.template:/etc/nginx/conf.d/default.conf
您應該執行以下操作: - ${PWD}/frontend/conf/nginx:/etc/nginx/conf.d
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.