简体   繁体   English

周末后无法在docker-compose中将文件挂载为卷,为什么?

[英]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.

相关问题 Docker-compose无效的bind mount spec“/ rootfs:ro”:无效的卷规范 - Docker-compose invalid bind mount spec “/rootfs:ro”: invalid volume specification windows 上 docker-compose 的卷名问题 - Volume name issue with docker-compose on windows 无法使用 docker-compose 将 docker 文件夹安装到主机中 - Unable to mount docker folder into host using docker-compose Docker-compose 卷不与本地文件同步,当我删除本地文件的卷时有效 - Docker-compose volumes not syncing with local files, works when I remove the volume for the local file bitnami consul 无法使用 docker 桌面卷挂载访问文件或目录 - bitnami consul cannot access file or directory using docker desktop volume mount docker-compose 错误:Windows 上的“没有这样的文件或目录” - docker-compose error: "no such file or directory" on Windows 来自 docker-compose 的 Docker 容器无法再连接到主机 - Docker containers from docker-compose cannot connect to host anymore 我想在 ZAEA23489CE3AA9B6304EBB28E0CD 上使用 docker-compose 将 windows 驱动器安装到 windows 容器中 - I want to mount a windows drive into a windows container using docker-compose on Windows wsl 上的 Docker-compose 无法在容器中启动终结器 - Docker-compose on wsl cannot start terminator in container 如何在 Docker 中为 windows 安装卷? - How to mount a volume in Docker for windows?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM