Skip to content

Commit d06422a

Browse files
author
ssuareza
committed
Fixing entrypoint.
0 parents  commit d06422a

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM alpine:3.7
2+
RUN apk --update add postgresql-client && rm -rf /var/cache/apk/*
3+
COPY . /
4+
ENTRYPOINT ["./entrypoint.sh"]

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
```

entrypoint.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
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 "$@"

0 commit comments

Comments
 (0)