I didn't use vagrant that much so take my answer with grain of salt. From my experience, I had to write a command line inside the vagrant file that specifies bash commands how to setup, run and install my application.
At the beginning I used it to run my application in an environment that is similar to production but comparing to Docker this is an overkill because I don't really need to install a big image of the operating system and the resources that the vagrant box took was high and I had a i3 core laptop with 6 GB RAM which means it slowed my laptop really bad.
Vagrant.configure("2") do |config|
$script = <<-SCRIPT
dnf install nodejs npm
cd /app
npm install
npm run serve
SCRIPT
config.vm.synced_folder "Users/smkd/Projects/my-react-app", "/app"
config.vm.box = "fedora/26-cloud-base"
config.ssh.forward_x11 = true
config.vm.provider :libvirt do |domain|
domain.cpus = 4
domain.memory = 30000
end
config.vm.provision "shell", inline: $script, privileged: true
end
In my current job we are using Docker. I am running it on Linux so I don't know how it is going to be on Windows or on MacOS because I heard that the user experience is different among them.
I am really happy with that choice. In Docker the image files are smaller and to setup the environment is very easy. I am sharing my code folder with the container environment although I had to tweak Dockerfile a little bit to set uid and gid to my Linux desktop otherwise it will run it as root and cause file permissions problems.
Anyway, I recommend on Docker.