is it possible to run virtualbox inside a docker c

2019-02-01 08:41发布

I tried running the container in privileged mode, but still the vboxdrv cannot be loaded.

I get

WARNING: The vboxdrv kernel module is not loaded. Either there is no module
     available for the current kernel (3.11.0-22-generic) or it failed to
     load. Please recompile the kernel module and install it by

       sudo /etc/init.d/vboxdrv setup

     You will not be able to start VMs until this problem is fixed.

2条回答
Viruses.
2楼-- · 2019-02-01 09:05

Yes, you can. You'll need to make sure you have the kernel module on your host system. I'm running Ubuntu, but I'm sure it'd be similar on other distros:

sudo apt-get install linux-headers-generic virtualbox-dkms

And make sure the kernel module is loaded:

sudo /etc/init.d/virtualbox status
VirtualBox kernel modules are loaded.

Now, run the docker container, and mount /dev/vboxdrv as a volume:

docker run -it -v /dev/vboxdrv:/dev/vboxdrv your/container-image
查看更多
forever°为你锁心
3楼-- · 2019-02-01 09:07

Edited at 2016-03-27 12:54 UTC

I have the exact same issue and I can successfully dockerize the latest version of VirtualBox with the Extension Pack and phpvirtualbox on CentOS 7.

You have to install tons of dependencies such as kernel-devel, make, gcc and dkms. After finishing the docker build, you MUST run the docker image with these flags --privileged=true -v /dev/:/dev/. you need the flag --privileged=true to run the image with the docker version of 1.10.3

For the details, please see my Dockerfile and run.sh

For the details, please have a look my repository especially Makefile, virtualbox.Dockerfile, vboxwebsrv.Dockerfile and phpvirtualbox.Dockerfile

查看更多
登录 后发表回答