|
|
||
|---|---|---|
| .. | ||
| containers.yml | ||
| hostvms.yml | ||
| README.md | ||
| Vagrantfile | ||
| VagrantfileHost | ||
Running Multiple Docker Containers in Vagrant with YAML
These files were created to allow users to use Vagrant (http://www.vagrantup.com) to quickly and relatively easily launch multiple Docker (http://www.docker.com) containers. The specifics of the Docker containers are specified in an external YAML file. The configuration was tested using Vagrant 1.8.5, VMware Fusion 8.1.0 (with the Vagrant VMware plugin), and VirtualBox 5.1.
Contents
-
containers.yml: This YAML file contains a list of the Docker containers and their properties for use by Vagrant. You will need to edit this file to specify container friendly name, image, and exposed ports.
-
hostvms.yml: This YAML file contains the configuration data for the "host VM" that the Vagrant Docker provider will use. Edit this file to change the Vagrant box used by the "host VM," or the VM configuration.
-
README.md: The file you're currently reading.
-
VagrantfileHost: This file is used by Vagrant to spin up a "host VM" for use with the Vagrant Docker provider. No edits should be necessary to this file.
-
Vagrantfile: This file is used by Vagrant to spin up the Docker containers on the host VM created by
VagrantfileHost. Unless you change filenames, you should not need to edit this file. All container details are stored in a separate YAML file.
Instructions
-
Use
vagrant box addto install an Ubuntu 14.04 base box. If you'd like to use a VMware Fusion-formatted box, you can use my base box ("slowe/ubuntu-trusty-x64"). -
Edit
hostvms.ymlto specify the name of the box you added in step #1. -
Edit the
containers.ymlfile to specify the Docker containers that Vagrant should create on the host VM. Each container should contain three properties:name(the friendly name to be assigned to the Docker container),image(the name of the Docker image to be used for this container), andports(a list of ports to be exposed for the container). -
From the directory where the main
Vagrantfileis located, simply runvagrant upto spin up the specified host VM and specified Docker containers. Note that Internet access will be required to download Docker and the Docker images.
Enjoy!