使用docker-compose发出安装docker volume的问题 [英] Issue mounting docker volume with docker-compose

查看:251
本文介绍了使用docker-compose发出安装docker volume的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 docker-compose.yml 文件构建docker swarm

I am trying to build docker swarm with docker-compose.yml file

version: '3'

services:
  myapp-nginx:
    image: nginx:1.10
    volumes:
     - ./nginx/certs:/etc/nginx/certs
    ports:
      - 80:80
      - 443:443

使用以下构建命令

$ docker stack deploy --compose-file docker-compose.yml myapp

Creating network myapp_default
Creating service myapp_myapp-nginx

我的系统具有 Docker版本17.03.1-ce-mac5(16048)

卷装载不起作用,如果我注释掉卷:-./ nginx / certs:/ etc / nginx / certs ,然后一切正常。

Volumes mounts are not working, If I comment out volumes: - ./nginx/certs:/etc/nginx/certs then everything works fine.

否则,nginx根本不起作用 p>

Otherwise nginx doesn't work at all, I see

CAGTAM1059934:docker iskumar$ docker stack ps myapp
ID            NAME                  IMAGE       NODE      DESIRED STATE  CURRENT STATE            ERROR                             PORTS
efjia8b7y6jd  myapp_myapp-nginx.1      nginx:1.10  manager1  Ready          Rejected 5 seconds ago   "invalid mount config for type…"  
c9c6ogh11osi   \_ myapp_myapp-nginx.1  nginx:1.10  worker2   Shutdown       Rejected 10 seconds ago  "invalid mount config for type…"  
iveikxpnbq6x   \_ myapp_myapp-nginx.1  nginx:1.10  worker1   Shutdown       Rejected 15 seconds ago  "invalid mount config for type…"  

是否有任何特殊的方式在docker-compose v3中装载卷?

Is there any special way to mount volumes in docker-compose v3?

推荐答案

我是从macbook运行 docker stack deploy 而不是在boot2docker VM上运行的。这就是为什么即使我使用 eval $(docker-machine env manager1)

I was running docker stack deploy from my macbook instead on boot2docker VMs. Which is why system couldn't find those network mount source, even though I had manager1 activated using eval $(docker-machine env manager1)

首先,我使用--no-trunc参数查看完整的错误消息。

First I used --no-trunc argument to view full error message.

$> docker node ps --no-trunc
---
Showed "invalid mount config for type "bind": bind source path does not exist"  
---

之后,将文件从主机系统( My MacBook )复制到VM,启动堆栈工作正常。

After that copies the files from host system (My MacBook) to VM and launching stack worked fine.

贷方 https ://github.com/docker/docker/issues/31202#issuecomment-281312704

这篇关于使用docker-compose发出安装docker volume的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆