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.

  • Mesos slave won't start docker
  • Docker-machine error in Linux
  • Docker: Different ENV variables for development and production environments
  • Ansible cannot import docker-py even though it is installed
  • docker makes port of container open to public
  • Docker compose environment and paths
  • - 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?

  • Starting Multiple service in Dockefile
  • Delete file inside docker container using java
  • Docker php_network_getaddresses error
  • Jenkins-node as docker container
  • docker container port format does not looks right(like <port>-<port>)
  • How to make docker service start on my system reboot automatically?
  • 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.