From a2b5b4d2e039be609f01df71f2c141dac56ec382 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20M=C3=B6hlmann?= Date: Sun, 18 Nov 2018 23:48:20 +0200 Subject: [PATCH] Declare the data volume properly --- optional/postgresql/Dockerfile | 8 ++++++-- optional/postgresql/start.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/optional/postgresql/Dockerfile b/optional/postgresql/Dockerfile index dbfc1dc8..14d11864 100644 --- a/optional/postgresql/Dockerfile +++ b/optional/postgresql/Dockerfile @@ -16,8 +16,12 @@ COPY start.py /start.py COPY conf /conf ENV LANG en_US.UTF-8 + +RUN mkdir -p /var/lib/postgresql/data /run/postgresql \ + && chown -R postgres:postgres /var/lib/postgresql/data /run/postgresql \ + && chmod 2777 /run/postgresql + +VOLUME /var/lib/postgresql/data EXPOSE 5432 -RUN mkdir -p /run/postgresql && chown -R postgres:postgres /run/postgresql && chmod 2777 /run/postgresql - CMD /start.py diff --git a/optional/postgresql/start.py b/optional/postgresql/start.py index f8bfc7d9..5880765e 100755 --- a/optional/postgresql/start.py +++ b/optional/postgresql/start.py @@ -20,7 +20,7 @@ def setup(): conn.close() # Bootstrap the database if postgresql is running for the first time -if not os.path.exists('/var/lib/postgresql/data/pg_hba.conf'): +if not os.path.exists('/var/lib/postgresql/data/pg_wal'): os.system("chown -R postgres:postgres /var/lib/postgresql") os.system("su - postgres -c 'initdb -D /var/lib/postgresql/data'")