I'm trying to set up Jenkins (runs in Docker; official image) which runs as user "jenkins". And Jenkins should start a virtual machine using docker-machine and virtualbox.
I bind-mounted /dev/vboxnetctl into the jenkins container. And I also tried to use sudo to run docker-machine as root.
But the user jenkins does not have access to /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
How to get this working?