Skip to content

madharjan/docker-postgresql-client

Repository files navigation

docker-postgresql-client

Build Status Layers

Docker container with PostgreSQL Client based on gliderlabs/alpine

Features

PostgreSQL Client 9.5 (docker-postgresql-client)

Environment

Variable Default Example
POSTGRESQL_HOST 192.168.1.1
POSTGRESQL_PORT 5432 1235
POSTGRESQL_DATABASE postgres mydb
POSTGRESQL_USERNAME postgres myuser
POSTGRESQL_PASSWORD mypass

Build

# clone project
git clone https://github.com/madharjan/docker-postgresql-client
cd docker-postgresql-client


# build
make

# tests
make run
make test

# clean
make clean

Run

Postgres Server (docker-postgresql)

# stop & remove previous instances
docker stop postgresql
docker rm postgresql
# run container
docker run -d \
  -e POSTGRESQL_PASSWORD=mypass \
  --name postgresql \
  madharjan/docker-postgresql:9.5

Postgres Client (docker-postgresql-client)

# psql console
docker run --rm -it \
  --link postgresql:db \
  -e POSTGRESQL_HOST=db \
  -e POSTGRESQL_PASSWORD=mypass \
  madharjan/docker-postgresql-client:9.5

# psql script
docker run --rm -it \
  --link postgresql:db \
  -e POSTGRESQL_HOST=db \
  -e POSTGRESQL_PASSWORD=mypass \
  madharjan/docker-postgresql-client:9.5 \
  -c 'select user from user'

Cleanup

docker stop postgresql
docker rm postgresql