Vagrant and Docker

2016-02-06 16:00:00
Posted in: Development
Views: 987

Using Vagrant and Docker to provision a LAMP and a MEAN container

This setup is tested on debian(3.16.7-ckt20-1+deb8u3)

Vagrantfile:
Vagrant.configure("2") do |config|
  #get ubuntu 64 bit image
  config.vm.box = "hashicorp/precise64"
  
  #run provisioning bash to setup docker in the vagrant/virtualbox env.
  config.vm.provision :shell, path: "bootstrap.sh" 
  
  #map port for LAMP stack (apache/web service only)
  config.vm.network :forwarded_port, guest: 8080, host: 8080
  
  #map port for MEAN stack (nodejs/web service only)
  config.vm.network :forwarded_port, guest: 3000, host: 3000
end

Bootstrap.sh:
#!/usr/bin/env bash


#update 
printf "\n\n\n Started server provisioning, please wait \n\n\n"

#get docker, and vim 
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo "deb https://apt.dockerproject.org/repo ubuntu-precise main" >> /etc/apt/sources.list
sudo apt-get update
sudo apt-get -y install docker-engine vim 

#get LAMP container
sudo docker search linode
sudo docker pull linode/lamp
sudo docker run -p 80:8080 -d -i linode/lamp /bin/bash 

#get MEAN container
sudo docker search meanjs
sudo docker pull maccam912/meanjs
sudo docker run -p 3000:3000 -d -i maccam912/meanjs /bin/bash

To get the files from the repo:

why-guy add:

Last Tweets: