Using Vagrant to create a PostgreSQL DB server

Vagrant looking for workI started using Vagrant a few months ago, and its been a real pleasure to use and has made my web development work so much more easier.

If you don't know what Vagrant is , then check it out at

Basically it allows you to create one or more virtual machines (VMs) on your own desktop or laptop.

So, for example, I use a Apple MacBook  and I use Vagrant to run Ubuntu 14 & Ubuntu 16 (at time of writing) VMs to do my development on.

This is the vagrant file I use to create the PostgreSQL server I use for development.

# -*- mode: ruby -*-
# vi: set ft=ruby :

setup = {
  "name": "MYVM_BOX",
  "ip_address": "",
  "memory": 512
Vagrant.configure("2") do |config|
  config.vm.define setup[:name] do |vb| :private_network, ip: setup[:ip_address] "forwarded_port", guest: 22, host: 5922, id: "ssh" "forwarded_port", guest: 5432, host: 5459 = "geerlingguy/ubuntu1604 "
    vb.vm.hostname = setup[:name]

    vb.vm.provider :virtualbox do |v|
    v.customize ["modifyvm", :id, "--memory", setup[:memory],"--nictype1", "virtio"]
    v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
    v.customize ["modifyvm", :id, "--natdnsproxy1", "on"]

    vb.vm.synced_folder ".", "/home/vagrant/shared"
    vb.vm.provision "shell", path: '',run: "once"


Leave a Reply

Your email address will not be published. Required fields are marked *