无法使用Rex-Ray和VirtualBox Media存储将持久卷装载到Docker容器 – “托pipe对象引用无效”错误

我正在尝试使用Rex-Ray插件将数据卷挂载到Docker容器。 我select了VirtualBox Media作为存储提供者。

我使用的版本是:

  • Docker 1.12.5
  • Rex-Ray 0.6.3和libStorage 0.3.5
  • VirtualBox基础包5.1.12

设置:

  • 一个在VirtualBox中运行的CentOS 7虚拟机
  • Docker 1.12.5在CentOS 7虚拟机上运行
  • Rex-Ray在CentOS 7虚拟机上安装并运行
  • Mac OS X 10.12.1主机

在Mac OS主机上:

1。 我用VBoxManage setproperty websrvauthlibrary nullclosuresVirtualBox SOAP APIauthentication

2。 我使用vboxwebsrv -H 0.0.0.0 -v启动VirtualBox SOAP API以允许Rex-Ray与VirtualBox进行通信

在CentOS 7虚拟机中,我正在做以下操作(以root身份):

1。 用systemctl start docker Docker启动Docker

2。 创buildRex-Ray /etc/rexray/config.yml文件:

 libstorage: service: virtualbox integration: volume: operations: mount: preempt: true virtualbox: endpoint: http://192.168.99.1:18083 volumePath: /Users/<username>/Volumes controllerName: SATA 

其中endpoint是VirtualBox SOAP API在Mac OS X主机上运行的IP, volumePath是Mac OS X主机上的一个现有文件夹,创build后将在其中存储卷

该configuration文件遵循https://github.com/codedellemc/labs/tree/master/setup-virtualbox-dockermachine上的Dell EMC教程中的相同格式

3。 使用rexray start启动Rex-Ray服务

4。 使用docker volume create -d rexray --name pg_data --opt=size=1 1GB卷docker volume create -d rexray --name pg_data --opt=size=1

5。 尝试使用官方postgres映像运行Postgres泊坞窗容器。 先前创build的rexray卷被挂载到Postgres容器中的/var/lib/postgresql/data目录中:

docker run -dit --name pg -e POSTGRES_PASSWORD=mysecretpassword --volume-driver=rexray -v pg_data:/var/lib/postgresql/data postgres

容器无法启动,我收到以下错误

Error response from daemon: VolumeDriver.Mount: {"Error":"VirtualBox error: Invalid managed object reference """}

我的VirtualBox存储设置如下图所示:

virtualbox存储设置

任何帮助非常感谢

问题在于VirtualBox存储设置中SATA控制器的端口数(默认情况下,链接在问题中的图像中显示)设置为1。

解决办法是把这个数字改成你认为你要装入的数量。

根据Rex-Ray文档,build议计数为30: http : //rexray.readthedocs.io/en/v0.3.3/user-guide/storage-providers/#virtualbox

以下configuration为我工作:

VirtualBox存储设置的图像