Wednesday, March 4, 2015

Docker - PostgreSQL Setup

Docker Installation: 

Ref: http://www.maori.geek.nz/post/boot_2_docker_how_to_set_up_postgres_elasticsearch_and_redis_on_mac_os_x


Execute following Commands in shell [Mac Os]

brew install boot2docker
boot2docker init boot2docker up
Important: Watch the output; Following lines are needed for setup
To connect the Docker client to the Docker daemon, please set:
    export DOCKER_HOST=tcp://192.168.59.103:2376
    export DOCKER_CERT_PATH=<dir>/.boot2docker/certs/boot2docker-vm
    export DOCKER_TLS_VERIFY=1

Setup:

 Execute the suggestion from `boot2docker up`
 And,  export DOCKER_IP=`boot2docker ip`



Run Postgres: 

Note: Change to desired password
docker run -it -e POSTGRES_PASSWORD=password -p 5432:5432 postgres


Stop Postgres:

Use 'Ctrl+C' to stop Postgrs server


Stop docker:

boot2docker stop


Rerun Docker/Postgres:

boot2docker up
Re-establish setup, if needed

docker run -it -e POSGRES_PASSWORD=password -p 5432:5432 postgres


Access:

pgAdmin3 - Use 'DOCKER_IP' address and 'postgres' user, password used in 'docker run'


For psql - With pgadmin3 installation

export PATH=$PATH:/Applications/pgAdmin3.app/Contents/SharedSupport


psql -h $DOCKER_IP -U postgres



Persistance

No persistence with above setup; Good for RoR Devels. 

No comments:

Post a Comment