is it possible to run virtualbox inside a docker container

前端 未结 3 1133
花落未央
花落未央 2020-12-24 01:57

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         


        
3条回答
  •  一生所求
    2020-12-24 02:54

    2019:

    • Virtualbox version: 6.0
    • Docker version: 18.09.6
    • Ubuntu 18.04

    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 :-)

提交回复
热议问题