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.

  • Execute command in linked docker container
  • How to Set Capabilities on Node Browser with selenium Docker
  • Where should i run my grunt build step when building my docker image for staging and production environments?
  • Is it possible to create ipv4-enabled Docker Machine on Windows 10?
  • How to edit files in a Confluence docker container? There is no vim and apt-get in it
  • Fig up error exec: “bundle”: executable file not found in $PATH
  • - proj1/
    -- Vagrantfile
    -- Vagrantfile.host
    - proj2/
    -- Vagrantfile
    -- Vagrantfile.host
    

    Each 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 Vagrantfile in proj1 points to a different docker image than the one in proj2.

    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?

  • Mapping django apps to docker containters, addressing with URLs
  • How can I remove the Cmd entry from a Docker image configuration?
  • Docker Volume not mounting any files
  • Docker DB connection refused
  • Increasing disk space for Agents/Worker nodes in Azure Container Service
  • java NIO memory map a docker mounted file fail
  • 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
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.