Skip to content

Commit

Permalink
Change Postgres config location
Browse files Browse the repository at this point in the history
Previously, the postgres configuration file was added to the
/var/lib/postgresql/data directory which was overwritten by the
already-existing named data volume. When initializing a database,
the placement of the configuration file in /var/lib/postgresql/data
caused an error that the "PGDATA was not empty."

This commit fixes this issue by placing the configuration file in
a different location (/etc/postgresql) and then running the Dockerfile
entrypoint with an argument showing the location of the config file.
  • Loading branch information
dchiller committed Feb 6, 2024
1 parent 724b0cf commit 11a4d60
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ services:
volumes:
- postgres_data:/var/lib/postgresql/data/
restart: always
command: -c 'config_file=/etc/postgresql/postgresql.conf'

volumes:
postgres_data:
Expand Down
2 changes: 1 addition & 1 deletion postgres/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM postgres:14-alpine
COPY postgresql.conf /var/lib/postgresql/data/postgresql.conf
COPY postgresql.conf /etc/postgresql/postgresql.conf
COPY postgres_backup.sh /usr/local/bin/postgres_backup.sh
RUN chmod +x /usr/local/bin/postgres_backup.sh

0 comments on commit 11a4d60

Please sign in to comment.