Use a single VM with Vagrant to host Docker Containers across multiple projects
I have two separate projects/src/code repos, using Vagrant to run an application in docker containers.
I am using Vagrant with a CentOS7 Host VM to host docker containers (https://www.vagrantup.com/docs/docker/basics.html). I am using a duplicate copy of the CentOS7 VM Vagrantfile (
Vagranfile.host) in each project.
- proj1/ -- Vagrantfile -- Vagrantfile.host - proj2/ -- Vagrantfile -- Vagrantfile.host
Vagrantfile points to
Vagrantfile.host to spin up a CentOS VM to host the Docker containers.
The only difference (effectively for this question) between the two projects is that the
proj1 points to a different docker image than the one in
When I do
vagrant up in each project folder, each one create’s it’s own CentOS7 VM instantiation, so I end up running two separate VirtualBox VMs.
Is there a way to change one or both of the
Vagrantfile files so that I end up only spinning up a single VM, and the containers both run in the same VirtualBox VM?
One Solution collect form web for “Use a single VM with Vagrant to host Docker Containers across multiple projects”
Got it to work. Not quite the way I wanted, but documenting for anyone who finds this question later. Point both Docker Vagrantfile’s to the same Vagrantfile.host for their linux parent.
- proj1/ -- Vagrantfile --> ./Vagrantfile.host -- Vagrantfile.host - proj2/ -- Vagrantfile --> ../proj1/Vagrantfile.host