简体   繁体   English

Docker共享卷创建

[英]Docker shared volume creation

I am trying to create a docker volume which will be shared between 2 hosts. 我正在尝试创建将在2个主机之间共享的docker卷。 Let's say that I have two hosts A and B. When the volume is created on host A with the following command: 假设我有两个主机A和B。使用以下命令在主机A上创建卷时:

docker volume create --driver local --opt type=nfs --opt o=addr=B,rw --opt device=:/tmp/dir --name foo

After inspection of volume, the result is the following: 检查体积后,结果如下:

  docker volume inspect foo
 [
    {
    "Name": "foo",
    "Driver": "local",
    "Mountpoint": "/var/lib/docker/volumes/foo/_data",
    "Labels": {},
    "Scope": "local"
    }
 ]

My question is: Why Mountpoint directory of volume doesn't point to directory /tmp/dir, but to default docker volume location? 我的问题是:为什么卷的Mountpoint目录不指向目录/ tmp / dir,而是指向默认的Docker卷位置? How I can consider that the data in directory host B/tmp/dir will be sharable? 我如何认为目录主机B / tmp / dir中的数据将可共享?

Thanks in advance! 提前致谢!

The volume you created does not match the inspect output. 您创建的卷与检查输出不匹配。 This would indicate that your volume create command failed, or perhaps you're checking the wrong host for the volume. 这表明您的卷创建命令失败,或者您正在检查错误的卷主机。 With the current version of docker, the expected output is: 在当前版本的docker中,预期输出为:

$ docker volume create --driver local --opt type=nfs \
         --opt o=addr=10.10.10.10,rw --opt device=:/path/to/dir nfs_test

$ docker volume inspect nfs_test                                       
[
    {
        "CreatedAt": "2018-02-18T12:10:03-05:00",
        "Driver": "local",
        "Labels": {},
        "Mountpoint": "/home/var-docker/volumes/nfs_test/_data",
        "Name": "nfs_test",
        "Options": {
            "device": ":/path/to/dir",
            "o": "addr=10.10.10.10,rw",
            "type": "nfs"
        },
        "Scope": "local"
    }
]

The output you produced matches a local volume created without any options: 您产生的输出与没有任何选项的本地卷匹配:

$ docker volume create foo

$ docker volume inspect foo
[
    {
        "CreatedAt": "2018-02-18T12:10:51-05:00",
        "Driver": "local",
        "Labels": {},
        "Mountpoint": "/home/var-docker/volumes/foo/_data",
        "Name": "foo",
        "Options": {},
        "Scope": "local"
    }
]

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

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