Docker container with PostgreSQL Client based on gliderlabs/alpine
- Bats bats-core/bats-core based test cases
Variable | Default | Example |
---|---|---|
POSTGRESQL_HOST | 192.168.1.1 | |
POSTGRESQL_PORT | 5432 | 1235 |
POSTGRESQL_DATABASE | postgres | mydb |
POSTGRESQL_USERNAME | postgres | myuser |
POSTGRESQL_PASSWORD | mypass |
# 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
# 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
# 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'
docker stop postgresql
docker rm postgresql