File tree Expand file tree Collapse file tree 3 files changed +27
-0
lines changed
Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 1+ FROM alpine:3.7
2+ RUN apk --update add postgresql-client && rm -rf /var/cache/apk/*
3+ COPY . /
4+ ENTRYPOINT ["./entrypoint.sh" ]
Original file line number Diff line number Diff line change 1+ # Postgresql Client
2+
3+ This client is compatible with the official postgresql image, which means that it uses the environment variables provided by the image.
4+
5+ ## Usage
6+
7+ ### Create a postgres database
8+
9+ ```
10+ docker run -e POSTGRES_HOST=host POSTGRES_USER=user -e POSTGRES_PASS=pwd -d --name=postgresql-client "CREATE DATABASE mydb;"
11+ ```
12+
13+ ### Use psql or pg_dump command
14+
15+ ```
16+ docker run --rm --link pg_container:db kalumkalac/postgresql-client:9.5 psql -c 'create database foo'
17+ docker run --rm --link pg_container:db -v /tmp/foo:/dump kalumkalac/postgresql-client:9.5 pg_dump foo -f /dump/dump_foo.sql
18+ ```
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ echo " ${POSTGRES_HOST} " :* :* :" ${POSTGRES_USER} " :" ${POSTGRES_PASS} " > ~ /.pgpass
3+ chmod 0600 ~ /.pgpass
4+ cat ~ /.pgpass
5+ psql -h ${POSTGRES_HOST} -U ${POSTGRES_USER} -w postgres -c " $@ "
You can’t perform that action at this time.
0 commit comments