summaryrefslogtreecommitdiffstats
path: root/Services/postgres
diff options
context:
space:
mode:
authorstartxfr <clarue@startx.fr>2014-11-20 09:34:55 +0100
committerstartxfr <clarue@startx.fr>2014-11-20 09:34:55 +0100
commit910a26141f16336c96e304ebe850a4e5a0f97f95 (patch)
treebc1eef413af3a0c1b7bd3eeda7ceafc8d6ed87b2 /Services/postgres
parent7f7d7e70ec819dbc4f1d88e29420e59549add0a9 (diff)
downloadphpmyadmin-910a26141f16336c96e304ebe850a4e5a0f97f95.tar.gz
phpmyadmin-910a26141f16336c96e304ebe850a4e5a0f97f95.tar.bz2
phpmyadmin-910a26141f16336c96e304ebe850a4e5a0f97f95.tar.xz
phpmyadmin-910a26141f16336c96e304ebe850a4e5a0f97f95.zip
modif des readme de chaque container pour etre plus expressif
Diffstat (limited to 'Services/postgres')
-rw-r--r--Services/postgres/Dockerfile2
-rw-r--r--Services/postgres/README.md41
-rw-r--r--Services/postgres/postgres_modify_pass.sh24
-rw-r--r--Services/postgres/postgres_run.sh14
4 files changed, 70 insertions, 11 deletions
diff --git a/Services/postgres/Dockerfile b/Services/postgres/Dockerfile
index 7997d9d..e863a45 100644
--- a/Services/postgres/Dockerfile
+++ b/Services/postgres/Dockerfile
@@ -1,5 +1,5 @@
FROM startx/fedora
-MAINTAINER Chistophe LARUE <dev@startx.fr>
+MAINTAINER Christophe LARUE <dev@startx.fr>
COPY postgres_run.sh postgres_modify_pass.sh /bin/
RUN yum -y install \
diff --git a/Services/postgres/README.md b/Services/postgres/README.md
index 73f4037..40881af 100644
--- a/Services/postgres/README.md
+++ b/Services/postgres/README.md
@@ -1,14 +1,35 @@
-STARTX docker-images - Postgres
-===============================
+# STARTX Services docker-images : PostgreSQL Server
+This container run postgres on fedora server.
-**Description**
-Based on the docker [default postgres](https://registry.hub.docker.com/u/library/postgres/) Dockerfile
+## Running from docker registry
-**Usage**
-
- docker run -d -p 5432:5432 startx/sv-postgres
- docker run -d -p 5432:5432 --name="test-postgres" startx/sv-postgres
+ # docker run -d -p 5432:5432 --name="postgres" startx/sv-postgres
+ # when linked to another container
+ # docker run -d --name="postgres" startx/sv-postgres
+ # docker run -d --name="php" --link postgres:postgres startx/sv-php
- docker run -d --name="test-postgres" startx/sv-postgres // linked to another container
- docker run -d --name="test-www" --link test-postgres:postgres startx/sv-php
+## Build and run from local Dockerfile
+### Building docker image
+Copy the sources to your docker host
+ mkdir startx-docker-images;
+ cd startx-docker-images;
+ git clone https://github.com/startxfr/docker-images.git .
+
+and build the container
+
+ docker build -t sv-postgres Services/postgres/
+
+### Running local image
+
+ # docker run -d -p 5432:5432 --name="postgres" sv-postgres
+
+## Accessing server
+
+ # psql -U postgres -h localhost -p 5432
+
+## Related Resources
+* [Sources files](https://github.com/startxfr/docker-images/tree/master/Services/postgres)
+* [Github STARTX profile](https://github.com/startxfr/docker-images)
+* [Docker registry for this container](https://registry.hub.docker.com/u/startx/sv-postgres/)
+* [Docker registry for Fedora](https://registry.hub.docker.com/u/fedora/)
diff --git a/Services/postgres/postgres_modify_pass.sh b/Services/postgres/postgres_modify_pass.sh
new file mode 100644
index 0000000..d76e189
--- /dev/null
+++ b/Services/postgres/postgres_modify_pass.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+if [ -f /.postgres_pass_modified ]; then
+ echo "PostgreSQL 'postgres' user pass already modified!"
+ exit 0
+fi
+
+#generate pasword
+PASS=${POSTGRES_PASS:-$(pwgen -s 12 1)}
+_word=$( [ ${POSTGRES_PASS} ] && echo "preset" || echo "random" )
+
+echo "=> Modifying 'postgres' user with a ${_word} password in PostgreSQL"
+sudo -u postgres psql -U postgres -d postgres -c "alter user postgres with password '$PASS';"
+echo "=> Done!"
+touch /.postgres_pass_modified
+
+echo "========================================================================"
+echo "You can now connect to this PostgreSQL Server using:"
+echo ""
+echo " psql -h <host> -p <port> --username=postgres"
+echo "and enter the password '$PASS' when prompted"
+echo ""
+echo "Please remember to change the above password as soon as possible!"
+echo "========================================================================" \ No newline at end of file
diff --git a/Services/postgres/postgres_run.sh b/Services/postgres/postgres_run.sh
new file mode 100644
index 0000000..dfbc232
--- /dev/null
+++ b/Services/postgres/postgres_run.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+#change the password
+service postgresql start >/dev/null 2>&1
+if [ ! -f /.postgres_pass_modified ]; then
+ /postgres_modify_pass.sh
+fi
+service postgresql stop >/dev/null 2>&1
+
+#start PostgreSQL
+sudo -u postgres /usr/lib/postgresql/9.3/bin/postgres -D /var/lib/postgresql/9.3/main -c config_file=/etc/postgresql/9.3/main/postgresql.conf
+
+
+exec /usr/libexec/mysqld \ No newline at end of file