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. Eit
2019:
The key is to use a docker image that has systemd running. I chose jrei/systemd-ubuntu
see here.
docker run -d --privileged \
--name systemd-ubuntu --network=host \
--device /dev/vboxdrv:/dev/vboxdrv \
-v /sys/fs/cgroup:/sys/fs/cgroup:ro \
-v /tmp:/tmp -it jrei/systemd-ubuntu
Inside the container I ran:
apt update
apt -y install wget
apt -y install gnupg2
apt -y install systemd
apt -y install software-properties-common
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | apt-key add -
wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | apt-key add -
add-apt-repository "deb https://download.virtualbox.org/virtualbox/debian bionic contrib"
apt update
apt -y install virtualbox-6.0
Enjoy :-)