How to make VM with Virtualbox (preferably with Vagrantfile), that allows running Dockerfile inside? (architecture: x86-64)
Objective: I would like to benefit from VirtualBox VM isolation (for safety), while run inside Docker (if not possible something that can run Dockerfile), as Dockerfile is very popular standard de facto. To make it "as a code" if possible, let's use Vagrantfile to define VirtualBox VM.
Non objective: using Vagrant with Docker as provider.
Hypothesis why it does not work: IDK, but I guess that it may have something to do with nested virtualization? As my objective is to utilize Virtualbox isolation of VM, then if needed, we can configure inside VM docker to be less "secure" if it will make it work, as we use VM for isolation here.
I tried different options, non works, so providing some files for easy copy&paste vagrant up start:
Alpine Vagrantfile: (does not work)
Vagrant.configure("2") do |config|
config.vm.box = "alpine/alpine64"
config.vm.provision "shell", inline: <<-SHELL
sudo apk update
sudo apk add docker
sudo rc-update add docker boot
sudo service docker start
SHELL
end
ArchLinux Vagrantfile: (does not work)
$script = <<-'SCRIPT'
pacman --noconfirm -Syyu
pacman --noconfirm -S docker
gpasswd -a vagrant docker
systemctl docker enable
systemctl docker start
SCRIPT
Vagrant.configure("2") do |config|
config.vm.box = "archlinux/archlinux"
config.vm.provider "virtualbox" do |v|
v.name = "Archlinux_With_Docker"
v.memory = 512
v.cpus = 2
end
config.vm.provision "shell", inline: $script
end