Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue #30 #38

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# Postgresql (http://www.postgresql.org/)

FROM phusion/baseimage:0.9.13
FROM phusion/baseimage:0.9.16
MAINTAINER Ryan Seto <[email protected]>

# Ensure we create the cluster with UTF-8 locale
RUN locale-gen en_US.UTF-8 && \
echo 'LANG="en_US.UTF-8"' > /etc/default/locale

# Disable SSH (Not using it at the moment).
RUN rm -rf /etc/service/sshd /etc/my_init.d/00_regen_ssh_host_keys.sh
#RUN rm -rf /etc/service/sshd /etc/my_init.d/00_regen_ssh_host_keys.sh

RUN /etc/my_init.d/00_regen_ssh_host_keys.sh

# Install the latest postgresql
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
Expand All @@ -18,6 +20,11 @@ RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" > /etc/
postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3 && \
/etc/init.d/postgresql stop

# work around for AUFS bug
# as per https://github.com/docker/docker/issues/783#issuecomment-56013588
RUN mkdir /etc/ssl/private-copy; mv /etc/ssl/private/* /etc/ssl/private-copy/; rm -r /etc/ssl/private; mv /etc/ssl/private-copy /etc/ssl/private; chmod -R 0700 /etc/ssl/private; chown -R postgres /etc/ssl/private


# Install other tools.
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y pwgen inotify-tools

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ $ mkdir -p /tmp/postgresql
$ docker run -d --name="postgresql" \
-p 127.0.0.1:5432:5432 \
-v /tmp/postgresql:/data \
-e USER="super" \
-e DB_USER="super" \
-e DB="database_name" \
-e PASS="$(pwgen -s -1 16)" \
paintedfox/postgresql
Expand All @@ -68,7 +68,7 @@ directory, and the superuser username and password on the host like so:
$ sudo mkdir -p /srv/docker/postgresql
$ make run PORT=127.0.0.1:5432 \
DATA_DIR=/srv/docker/postgresql \
USER=super \
DB_USER=super \
PASS=$(pwgen -s -1 16)
```

Expand All @@ -88,7 +88,7 @@ password for the superuser. To view the login in run `docker logs

``` shell
$ docker logs postgresql
POSTGRES_USER=super
POSTGRES_DB_USER=super
POSTGRES_PASS=b2rXEpToTRoK8PBx
POSTGRES_DATA_DIR=/data
Starting PostgreSQL...
Expand Down Expand Up @@ -136,7 +136,7 @@ $ psql -U "$DB_ENV_USER" \
-p "$DB_PORT_5432_TCP_PORT"
```

If you ran the *postgresql* container with the flags `-e USER=<user>` and `-e
If you ran the *postgresql* container with the flags `-e DB_USER=<user>` and `-e
PASS=<pass>`, then the linked container should have these variables available
in its environment. Since we aliased the database container with the name
*db*, the environment variables from the database container are copied into the
Expand Down
4 changes: 2 additions & 2 deletions scripts/first_run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
USER=${USER:-super}
USER=${DB_USER:-super}
PASS=${PASS:-$(pwgen -s -1 16)}

pre_start_action() {
Expand All @@ -13,7 +13,7 @@ pre_start_action() {
echo "Initializing PostgreSQL at $DATA_DIR"

# Copy the data that we generated within the container to the empty DATA_DIR.
cp -R /var/lib/postgresql/9.3/main/* $DATA_DIR
cp -aR /var/lib/postgresql/9.3/main/* $DATA_DIR
fi

# Ensure postgres owns the DATA_DIR
Expand Down