[英]Cannot mount file as a volume in docker-compose after weekends, why?
Today i got new error in my docker-environment. 今天,我在docker环境中遇到了新错误。 I just started my project (Web, Php and Postgres Containers), but Nginx container dont started, because the site.conf, which i mount with volumes is a "directory".
我刚刚启动了我的项目(Web,Php和Postgres容器),但是Nginx容器没有启动,因为我随卷一起安装的site.conf是一个“目录”。
Last friday it was ok and worked nice for me. 上周五,还可以,对我来说很好。 I dont change anything in this case.
在这种情况下,我不做任何更改。 ;(
(
I created extra docker-compose file, where you can try to reproduce my error. 我创建了额外的docker-compose文件,您可以在其中尝试重现我的错误。
docker-compose File: docker-compose文件:
version: "3"
services:
nginx:
container_name: nginxCr
image: nginx:1.15.7
ports:
- "80:80"
volumes:
- .:/var/www
- ./site.conf:/etc/nginx/conf.d/site.conf
site.conf can be empty for testing. site.conf可以为空以进行测试。
after docker-compose up -d Container is not running. 在docker-compose up -d容器未运行之后。
docker logs nginxCr provides following: docker日志nginxCr提供以下内容:
2019/03/04 14:49:25 [crit] 1#1: pread() "/etc/nginx/conf.d/site.conf" failed (21: Is a directory) nginx: [crit] pread() "/etc/nginx/conf.d/site.conf" failed (21: Is a directory)
2019/03/04 14:49:25 [crit] 1#1:pread()“ /etc/nginx/conf.d/site.conf”失败(21:是目录)nginx:[crit] pread() “ /etc/nginx/conf.d/site.conf”失败(21:是目录)
Somehow start the docker (docker compose) to creating directory instead of linking my config file. 以某种方式启动docker(docker撰写)以创建目录,而不是链接我的配置文件。
I have Windows 10 Pro (Build 17134) 我有Windows 10 Pro(内部版本17134)
Docker version 18.09.2, build 6247962 Docker版本18.09.2,内部版本6247962
docker-compose version 1.23.2, build 1110ad01 docker-compose版本1.23.2,内部版本1110ad01
UPDATE: Problem seems to be Windows only... on my Nix-Server it works fine 更新:问题似乎仅是Windows ...在我的Nix服务器上,它工作正常
the solution was to uncheck -> apply
解决的办法是
uncheck -> apply
and then 接着
check -> apply
the Harddrive in "Shared Drivers" in Docker-Settings check -> apply
在Docker设置的“共享驱动程序”中check -> apply
硬盘
*facepalm* *捂脸*
Keep your www
files in a sperate folder instead of .
将
www
文件保存在一个单独的文件夹中,而不是.
. 。 Have a compose file like below:
具有如下的撰写文件:
services:
nginx:
container_name: nginxCr
image: nginx:1.15.7
ports:
- "80:80"
volumes:
- ./www:/var/www
- ./site.conf:/etc/nginx/conf.d/site.conf
So, in your Present working Dir you should have a folder called www
(so that you don't have to merge volumes) and a file called site.conf
. 因此,在当前工作目录中,您应该有一个名为
www
的文件夹(这样就不必合并卷)和一个名为site.conf
的文件。 Even if it is an empty file, you should have it in your directory. 即使它是一个空文件,也应将其放在目录中。 Otherwise,
docker
will create a folder in that name. 否则,
docker
将使用该名称创建一个文件夹。
In case if you have a folder called site.conf
, delete that folder and do touch site.conf
, then do docker-compose up -d
如果您有一个名为
site.conf
的文件夹,请删除该文件夹并touch site.conf
,然后执行docker-compose up -d
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.