简体   繁体   English

码头工人| 安装卷导致错误

[英]Docker | Mounting volumes causes error

I am trying to setup a Docker swarm which connects 3 of my servers together. 我正在尝试设置将3个服务器连接在一起的Docker群。 The swarm is setup and going to the URL I get the same result, which is perfect and just what I need. 蜂拥而至,设置URL,我得到了相同的结果,这是完美的,正是我所需要的。

However, for the server in which I am working on now I am producing a global nginx on every server in order to allow load balancing. 但是,对于我现在正在使用的服务器,为了允许负载平衡,我在每台服务器上都生成一个全局nginx。

Sitting on the server will be multiple config files which I need in order to map the domain to the correct folder, which is the part which I am stuck on/not working for me. 坐在服务器上的是多个配置文件,我需要这些配置文件才能将域映射到正确的文件夹,这是我无法使用或无法使用的部分。

I have a really simple docker-compose.yml as I have shrunk it in order to debug the issue, it consists of the following... 我有一个非常简单docker-compose.yml因为我已将其缩小以调试问题,它包含以下内容...

version: '3'
  services:
    nginx:
      image: nginx:latest
    volumes:
      - /var/www/nginx/config/:/etc/nginx/conf.d/:ro
    deploy:
      mode: global

The volume is coming back with the error "invalid mount config for type "bind": bind source path does not exist" so obviously when I remove the volume line it works perfectly, however I 100% need this line. 该卷返回错误"invalid mount config for type "bind": bind source path does not exist"因此很明显,当我删除卷行时,它可以正常工作,但是我100%需要此行。

I can, inside of the server navigate perfectly to /var/www/nginx/config/ and my config files exist within. 我可以在服务器内部完美导航到/var/www/nginx/config/并且我的配置文件位于其中。 Same with the other, if I run docker exec -it <container> /bin/bash and navigate to /etc/nginx/conf.d I can get to there perfectly fine which is why I'm posting on here. 与其他相同,如果我运行docker exec -it <container> /bin/bash并导航到/etc/nginx/conf.d我可以到达那里很好,这就是为什么我在这里发布。

I've looked at other posts and done what other people have said have fixed it such as 我看过其他帖子,并做了其他人所说的修复问题,例如

  • Adding quotes to the volume 在卷中添加引号
  • Remove the slash at the end of the file 删除文件末尾的斜杠
  • Restart the server 重新启动服务器
  • Restart Docker 重新启动Docker

But nothing seems to be working 但是似乎没有任何作用

The potential issue could be that not all the nodes in your swarm cluster have the directory ( /var/www/nginx/config/ ) created. 潜在的问题可能是,并非群集集群中的所有节点都具有创建的目录( /var/www/nginx/config/ )。 Since in swarm the service can be placed in any of the available nodes(unless you put in a constraint) you might be seeing this error. 由于可以将服务放入大量可用节点中(除非您施加了约束),因此您可能会看到此错误。

Make sure that you have this directory created in all the 3 nodes. 确保在所有3个节点中都创建了此目录。

Additionally you can also have a look here for defining configs. 此外,您还可以在此处查看定义配置的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM