Here is an easy guide on how to manage container Docker with Vagrant. This guide is tested on Rackspace Cloud Server and will work on all OpenStack IaaS. We already know what is Container Based Virtualization and how to use Docker on Cloud Server to Manage Containers. It is actually possible to Manage Docker with Vagrant on OpenStack Cloud Server – “Vagrant 1.6 comes with a new built-in provider: Docker”. We can not say whether it is possible to do with OpenShift Origin.
Disambiguation of the Names : OpenShift is Open Source PaaS software by RedHat, while OpenStack is intended for IaaS, initially developed by NASA and Rackspace. OpenShift can run on OpenStack, vice versa is not possible.
Manage Docker with Vagrant on OpenStack Cloud Server : Get Started
We will get started by installing Vagrant 1.6.x and Docker 1.1.x on Ubuntu Trusty (14.04 LTS) on Rackspace Performance 1 Flavor (PVHVM). While PVHVM is used for better performance, usage of 2GB instance (at this moment of publishing this article) will provide virtual dual core processor. Assuming that we are using a Mac (OS X 10.9.x) or any GNU Linux, we can use Docker on local computing via Boot2Docker :
# official instructions
# github repo
Boot2Docker uses a Vagrant VirtualBox VM with Docker on it. As post installation process, we will set the environment variable
# edit using nano
# check version manually
wget https://dl.bintray.com/mitchellh/vagrant/vagrant_1.6.3_x86_64.deb && dpkg -i vagrant_1.6.3_x86_64.deb
# we are working via SSH - make sure that you have understood our plan
sudo apt-get install lxc-docker-1.1.1
We did it, so that Vagrant is forced to use Docker by default.
Example of How We Can Manage Docker with Vagrant
We can create a
vagrantfile to manage our Docker container based on this list of cookbook :
# example with mongo db
You can use any of the recipe to test (or taste!). You can read about Vagrant configuration :
If there is any problem with Path on VM (in case it is local computer), go to
/vagrant/scripts and add the following line on
setup.sh file :
echo "source /vagrant/scripts/export.sh" >> /home/vagrant/.bashrc
Below is an example
vagrantfile, but look at the Docker hub first :
This is an edited
vagrantfile for mongo :
Vagrant.configure("2") do |config|
config.vm.provider "docker" do |d|
d.image = "quintenk/mongo"
d.has_ssh = false
d.ports = ["27017:27017"]
d.volumes = ["/data/mongo:/root/.mongo"]
For VM (local computer), the vagrant file might need some alteration.
This file contains a single configuration block as per documentation.
docker notation declares a Docker instance and variable name is
d, simply run Vagrant :
Note that, this IS A COMPLICATED example as it is mongo db and port can not be 8080. You can start with any cookbook which uses the port 8080.
Follow the Author of this article :