Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is it possible to run virtualbox inside a docker container

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. 
like image 432
babbata Avatar asked Sep 09 '14 10:09

babbata


People also ask

Can you run VirtualBox in docker?

Docker machines runs as a VirtualBox virtual machine as you're using the VirtualBox Docker Machine driver. So, it uses up your system memory (RAM). You may not want to run all the Docker machines at the same time. Instead, run only the machines you need.

Does docker need VirtualBox?

No, you don't need virtual box to run docker containers. You might want to look What is docker machine, because it needs virtual host. You only need a virtual machine to run docker on a non Linux box.

What is the difference between docker and VirtualBox?

Docker is an application virtualisation tool. VirtualBox is a Virtual Machine tool. VB simulates an entire hardware environment whereas Docker isolates the reads/writes of the enclosed application from the rest of the OS.


1 Answers

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 
like image 111
Dana Avatar answered Oct 02 '22 23:10

Dana