How to use zaiste/postgresql Docker container.
Docker >= 0.5.0 required.
docker pull zaiste/postgresql
CONTAINER=$(docker run -d zaiste/postgresql)
CONTAINER_IP=$(docker inspect $CONTAINER | grep IPAddress | awk '{ print $2 }' | tr -d ',"')
psql -h $CONTAINER_IP -p 5432 -d docker -U docker -W
password for user docker:
psql (9.2.4)
Type "help" for help.
docker=# create database foo owner=docker;
CREATE DATABASE
I've got a recommendation for parsing out the ip address.
I installed the jq command line tool like so...
Now, instead of using grep, awk, and tr, you can run the following...
CONTAINER_IP=$(sudo docker inspect $POSTGRES_CONTAINER | jq -r '.[0].NetworkSettings.IPAddress')
The
-r
switch means give the raw output, otherwise the command will put quotes around the ip address.