Vagrant with Docker Postgres

I know this is a very simple blog. However, when you are first starting out with some technology, sometimes its good to get something up and running to get a “feel” for how something works…

So, to get a basic Vagrant box up and running with Postgres hosted in a Docker container.

  1. Install Vagrant for your particular operating system
  2. Create a folder/directory, in this case I named my folder “v-docker-postgres” (horrible name?)
  3. Create a file within this folder named: Vagrantfile
  4. Inside the Vagrantfile, save the following content:Vagrant.configure(“2”) do |config| = “wesmcclure/ubuntu1404-docker”

    config.vm.define “acm-db” do |db|
    db.vm.provision “shell”, path: “./provision/”
    db.vm.hostname = “acm-db” “private_network”, ip: “”

  5. This box is provided by Wes, who has an excellent course on Vagrant on Pluralsight. Go check it out.
  6. With the above in place, create folder in “v-docker-postgres” called, “provision”
  7. Create a file within “provision” named “”. This is the same name we used in the above Vagrantfile
  8. Inside the “db-setup” file save the following content:#!/usr/bin/env bash

    docker run -d \
    –name postgres \
    -p 5432:5432 \
    –restart unless-stopped \

  9. With all of the above in place, you should now be able to fire this up by opening a terminal/command prompt/bash shell inside the “v-docker-postgres” folder/directory and execute the command: “vagrant up”
  10. If everything has gone well, you should now be able to connect to your database on IP: PORT: 5432

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s