无法使用 Rex-Ray 和 VirtualBox 媒体存储将持久卷安装到 Docker 容器 - "Invalid managed object reference" 错误

Unable to mount persistent volume to Docker container using Rex-Ray and VirtualBox Media storage - "Invalid managed object reference" error

我正在尝试使用 Rex-Ray 插件将数据卷装载到 docker 容器。我选择了 VirtualBox Media 作为存储提供程序。

我使用的版本是:

设置:

在Mac OS主机上:

1。我使用 VBoxManage setproperty websrvauthlibrary null

关闭 VirtualBox SOAP API 身份验证

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

在 CentOS 7 VM 中,我正在执行以下操作(作为 root):

1。从 Docker 开始 systemctl start docker

2。创建 Rex-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 是 Mac OS X 主机上的 VirtualBox SOAP API 运行 所在的 IP,volumePath 是 Mac OS X 主机上的现有文件夹,创建后将在其中存储卷

此配置文件遵循 https://github.com/codedellemc/labs/tree/master/setup-virtualbox-dockermachine

上的 Dell EMC 教程中的相同格式

3。使用 rexray start

启动 Rex-Ray 服务

4。创建一个 1GB 的卷 docker volume create -d rexray --name pg_data --opt=size=1

5。尝试使用官方 postgres 图像 运行 Postgres docker 容器。之前创建的 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 storage settings

非常感谢任何帮助

问题是 VirtualBox 存储设置中 SATA 控制器的端口数(如问题中链接的图像所示)默认设置为 1。

解决方案是将此计数更改为您认为要装载的卷数。

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

以下配置对我有用: