Docker 中的 Jenkins 无法访问 VirtualBox 的 /dev/vboxnetctl

Docker 中的 Jenkins 无法访问 VirtualBox 的 /dev/vboxnetctl

我正在尝试设置以用户“jenkins”运行的 Jenkins(在 Docker 中运行;官方映像)。 Jenkins 应该使用 docker-machine 和 virtualbox 启动虚拟机。

我将 /dev/vboxnetctl 绑定安装到 jenkins 容器中。我还尝试使用 sudo 以 root 身份运行 docker-machine 。

但用户 jenkins 无权访问 /dev/vboxnetctl:

$ docker-compose exec jenkinsmaster sudo docker-machine create test
Creating CA: /root/.docker/machine/certs/ca.pem
Creating client certificate: /root/.docker/machine/certs/cert.pem
Running pre-create checks...
(test) Image cache directory does not exist, creating it at /root/.docker/machine/cache...
(test) No default Boot2Docker ISO found locally, downloading the latest release...
(test) Latest release for github.com/boot2docker/boot2docker is v17.09.0-ce
(test) Downloading /root/.docker/machine/cache/boot2docker.iso from https://github.com/boot2docker/boot2docker/releases/download/v17.09.0-ce/boot2docker.iso...
(test) 0%....10%....20%....30%....40%....50%....60%....70%....80%....90%....100%
Creating machine...
(test) Copying /root/.docker/machine/cache/boot2docker.iso to /root/.docker/machine/machines/test/boot2docker.iso...
(test) Creating VirtualBox VM...
(test) Creating SSH key...
(test) Starting the VM...
(test) Check network to re-create if needed...
(test) Creating a new host-only adapter produced an error: /usr/bin/VBoxManage hostonlyif create failed:
(test) 0%...
(test) Progress state: NS_ERROR_FAILURE
(test) VBoxManage: error: Failed to create the host-only adapter
(test) VBoxManage: error: VBoxNetAdpCtl: Error while adding new interface: failed to open /dev/vboxnetctl: Operation not permitted
(test) VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component HostNetworkInterfaceWrap, interface IHostNetworkInterface
(test) VBoxManage: error: Context: "RTEXITCODE handleCreate(HandlerArg*)" at line 71 of file VBoxManageHostonly.cpp
(test) 
(test) This is a known VirtualBox bug. Let's try to recover anyway...
Error creating machine: Error in driver during machine creation: Error setting up host only network on machine start: The host-only adapter we just created is not visible. This is a well known VirtualBox bug. You might want to uninstall it and reinstall at least version 5.0.12 that is is supposed to fix this issue

如何让它发挥作用?

相关内容