If, when you start your Docker Compose, you're getting:

PostgreSQL Database directory appears to contain a database; Skipping initialization

you need to proactively remove the volumes which were set up to store the database.

The command docker-compose down doesn't do this automatically.

You can request removal of volumes like this:

docker-compose down --volumes

Be warned that this will delete any data you had in any database before. You can't get this data back if you remove the volume which contained it!

Answer from LondonRob on Stack Overflow
🌐
Docker Community
forums.docker.com › docker desktop
The postgres container cannot start in docker - Docker Desktop - Docker Community Forums
October 20, 2020 - I tried to start the postgres container in docker but kept receiving below error message: PostgreSQL Database directory appears to contain a database; Skipping initialization FATAL: could not open directory "pg_tblspc": No such file or directory LOG: database system is shut down The postgres ...
🌐
Reddit
reddit.com › r/unraid › postgressql for immich : postgresql database directory appears to contain a database; skipping initialization - message
r/unRAID on Reddit: PostgresSQL for Immich : PostgreSQL Database directory appears to contain a database; Skipping initialization - message
January 23, 2025 -

Hello everyone, I am pretty new to Unraid. I have a Postgres Docker on my Unraid 7 Server. After a the update to Unraid 7 Immich started like a fresh install. I restored Immich and Postgres with a Backup from Easybackup. After restoring the Postgres Docker I get a massage in the protocol I dont understand. Can somebody explain how to get the service back running? I am not used to command line.

Protocol:

2025-01-23 12:54:15.790 CET [27] LOG: checkpoint starting: time

2025-01-23 12:54:16.697 CET [27] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.005 s, sync=0.202 s, total=0.908 s; sync files=2, longest=0.161 s, average=0.101 s; distance=0 kB, estimate=0 kB; lsn=0/669AB08, redo lsn=0/669AAD0

2025-01-23 13:14:15.995 CET [27] LOG: checkpoint starting: time

2025-01-23 13:14:17.225 CET [27] LOG: checkpoint complete: wrote 6 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.610 s, sync=0.290 s, total=1.231 s; sync files=3, longest=0.170 s, average=0.097 s; distance=24 kB, estimate=24 kB; lsn=0/66A0B48, redo lsn=0/66A0B10

2025-01-23 13:18:59.492 CET [1] LOG: received fast shutdown request

2025-01-23 13:18:59.608 CET [1] LOG: aborting any active transactions

2025-01-23 13:18:59.618 CET [1] LOG: background worker "logical replication launcher" (PID 37) exited with exit code 1

2025-01-23 13:18:59.622 CET [27] LOG: shutting down

2025-01-23 13:18:59.795 CET [27] LOG: checkpoint starting: shutdown immediate

2025-01-23 13:19:00.173 CET [27] LOG: checkpoint complete: wrote 0 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.002 s, sync=0.001 s, total=0.552 s; sync files=0, longest=0.000 s, average=0.000 s; distance=0 kB, estimate=21 kB; lsn=0/66A0BF8, redo lsn=0/66A0BF8

2025-01-23 13:19:00.222 CET [1] LOG: database system is shut down

2025-01-23 11:25:55.336 CET [1] LOG: starting PostgreSQL 16.2 (Debian 16.2-1.pgdg120+2) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit

2025-01-23 11:25:55.355 CET [1] LOG: listening on IPv4 address "0.0.0.0", port 5432

2025-01-23 11:25:55.355 CET [1] LOG: listening on IPv6 address "::", port 5432

2025-01-23 11:25:55.562 CET [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"

2025-01-23 11:25:55.595 CET [29] LOG: database system was shut down at 2025-01-23 13:18:59 CET

[2025-01-23T10:25:55Z INFO service::utils::clean] Find directory "pg_vectors/indexes/17347".

[2025-01-23T10:25:55Z INFO service::utils::clean] Find directory "pg_vectors/indexes/17591".

2025-01-23 11:25:55.776 CET [1] LOG: database system is ready to accept connections

2025-01-23 11:30:55.644 CET [27] LOG: checkpoint starting: time

2025-01-23 11:30:56.054 CET [27] LOG: checkpoint complete: wrote 5 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.207 s, sync=0.126 s, total=0.411 s; sync files=4, longest=0.049 s, average=0.032 s; distance=1 kB, estimate=1 kB; lsn=0/66A1038, redo lsn=0/66A1000

2025-01-23 12:30:55.906 CET [27] LOG: checkpoint starting: time

2025-01-23 12:30:56.202 CET [27] LOG: checkpoint complete: wrote 2 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.104 s, sync=0.099 s, total=0.296 s; sync files=2, longest=0.063 s, average=0.050 s; distance=0 kB, estimate=0 kB; lsn=0/66A13D8, redo lsn=0/66A13A0

2025-01-23 13:10:55.786 CET [27] LOG: checkpoint starting: time

2025-01-23 13:10:56.225 CET [27] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.305 s, sync=0.086 s, total=0.439 s; sync files=2, longest=0.055 s, average=0.043 s; distance=10 kB, estimate=10 kB; lsn=0/66A3C80, redo lsn=0/66A3C48

2025-01-23 13:15:47.947 CET [1] LOG: received fast shutdown request

2025-01-23 13:15:48.427 CET [1] LOG: aborting any active transactions

2025-01-23 13:15:48.437 CET [1] LOG: background worker "logical replication launcher" (PID 37) exited with exit code 1

2025-01-23 13:15:48.441 CET [27] LOG: shutting down

2025-01-23 13:15:48.463 CET [27] LOG: checkpoint starting: shutdown immediate

2025-01-23 13:15:48.822 CET [27] LOG: checkpoint complete: wrote 0 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.003 s, sync=0.001 s, total=0.381 s; sync files=0, longest=0.000 s, average=0.000 s; distance=0 kB, estimate=9 kB; lsn=0/66A3D30, redo lsn=0/66A3D30

2025-01-23 13:15:48.863 CET [1] LOG: database system is shut down

2025-01-23 13:26:17.929 CET [1] LOG: starting PostgreSQL 16.2 (Debian 16.2-1.pgdg120+2) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit

2025-01-23 13:26:17.929 CET [1] LOG: listening on IPv4 address "0.0.0.0", port 5432

2025-01-23 13:26:17.929 CET [1] LOG: listening on IPv6 address "::", port 5432

2025-01-23 13:26:18.063 CET [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"

2025-01-23 13:26:18.096 CET [29] LOG: database system was shut down at 2025-01-23 13:15:48 CET

[2025-01-23T12:26:18Z INFO service::utils::clean] Find directory "pg_vectors/indexes/17347".

[2025-01-23T12:26:18Z INFO service::utils::clean] Find directory "pg_vectors/indexes/17591".

2025-01-23 13:26:18.137 CET [1] LOG: database system is ready to accept connections

2025-01-23 13:31:18.172 CET [27] LOG: checkpoint starting: time

2025-01-23 13:31:18.301 CET [27] LOG: checkpoint complete: wrote 4 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.106 s, sync=0.007 s, total=0.129 s; sync files=3, longest=0.003 s, average=0.003 s; distance=1 kB, estimate=1 kB; lsn=0/66A4168, redo lsn=0/66A4130

2025-01-23 13:43:58.822 CET [1] LOG: received fast shutdown request

2025-01-23 13:43:58.826 CET [1] LOG: aborting any active transactions

2025-01-23 13:43:58.837 CET [1] LOG: background worker "logical replication launcher" (PID 43) exited with exit code 1

2025-01-23 13:43:58.838 CET [27] LOG: shutting down

2025-01-23 13:43:58.841 CET [27] LOG: checkpoint starting: shutdown immediate

2025-01-23 13:43:58.859 CET [27] LOG: checkpoint complete: wrote 0 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.003 s, sync=0.001 s, total=0.022 s; sync files=0, longest=0.000 s, average=0.000 s; distance=0 kB, estimate=0 kB; lsn=0/66A4218, redo lsn=0/66A4218

2025-01-23 13:43:58.903 CET [1] LOG: database system is shut down

2025-01-23 13:58:36.431 CET [1] FATAL: could not open directory "pg_notify": No such file or directory

2025-01-23 13:58:36.446 CET [1] LOG: database system is shut down

2025-01-23 13:59:10.060 CET [1] FATAL: could not open directory "pg_notify": No such file or directory

2025-01-23 13:59:10.076 CET [1] LOG: database system is shut down

2025-01-23 13:59:18.515 CET [1] FATAL: could not open directory "pg_notify": No such file or directory

2025-01-23 13:59:18.529 CET [1] LOG: database system is shut down

2025-01-23 13:59:39.578 CET [1] FATAL: could not open directory "pg_notify": No such file or directory

2025-01-23 13:59:39.593 CET [1] LOG: database system is shut down

2025-01-23 14:03:19.124 CET [1] FATAL: could not open directory "pg_notify": No such file or directory

2025-01-23 14:03:19.140 CET [1] LOG: database system is shut down

2025-01-23 14:03:31.577 CET [1] FATAL: could not open directory "pg_notify": No such file or directory

2025-01-23 14:03:31.592 CET [1] LOG: database system is shut down

2025-01-23 14:21:43.381 CET [1] FATAL: could not open directory "pg_notify": No such file or directory

2025-01-23 14:21:43.396 CET [1] LOG: database system is shut down

PostgreSQL Database directory appears to contain a database; Skipping initialization

PostgreSQL Database directory appears to contain a database; Skipping initialization

PostgreSQL Database directory appears to contain a database; Skipping initialization

PostgreSQL Database directory appears to contain a database; Skipping initialization

PostgreSQL Database directory appears to contain a database; Skipping initialization

PostgreSQL Database directory appears to contain a database; Skipping initialization

PostgreSQL Database directory appears to contain a database; Skipping initialization

PostgreSQL Database directory appears to contain a database; Skipping initialization

PostgreSQL Database directory appears to contain a database; Skipping initialization

🌐
Reddit
reddit.com › r/unraid › issue when restarting postgresql (all versions but currently using 15)
r/unRAID on Reddit: issue when restarting Postgresql (all versions but currently using 15)
November 26, 2023 -

For a while now I have been having issues with my postgres sql docker stopping and not starting up again, and killing my authentik application.
I recently discovered that this is happening after the docker gets restarted and I get this in logs.

PostgreSQL Database directory appears to contain a database; Skipping initialization

i also discovered this post about a similar issue mentioning the error, but no solution that i believe i can apply to my unraid docker to stop the problem
https://stackoverflow.com/questions/59715622/docker-compose-and-create-db-in-postgres-on-init
(it mentions about removing the volumes/data but that resets it :( )

(i have never experienced this with mariaDB after a restart, sadly i can't use it for authentik)
If anyone has experienced this before please let me know on the solution.

🌐
GitHub
github.com › docker-library › postgres › issues › 941
Postgres not actually up when initialization script is run on a new container image, not accepting connections. · Issue #941 · docker-library/postgres
March 8, 2022 - PostgreSQL Database directory appears to contain a database; Skipping initialization 2022-03-08 14:34:38.679 UTC [1] LOG: starting PostgreSQL 14.2 (Debian 14.2-1.pgdg110+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit 2022-03-08 14:34:38.679 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 2022-03-08 14:34:38.679 UTC [1] LOG: listening on IPv6 address "::", port 5432 2022-03-08 14:34:38.681 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2022-03-08 14:34:38.686 UTC [28] LOG: database system was interrupted; last kn
Author   docker-library
🌐
Docker
docs.docker.com › guides › pre-seeding database with schema and data at startup for development environment
Pre-seeding database with schema and data at startup for development environment | Docker Docs
3 weeks ago - PostgreSQL Database directory appears to contain a database; Skipping initialization 2024-09-08 09:09:47.136 UTC [1] LOG: starting PostgreSQL 16.4 (Debian 16.4-1.pgdg120+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit 2024-09-08 09:09:47.137 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 2024-09-08 09:09:47.137 UTC [1] LOG: listening on IPv6 address "::", port 5432 2024-09-08 09:09:47.139 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2024-09-08 09:09:47.142 UTC [29] LOG: database system was shut down at 2024-09-08 09:07:09 UTC 2024-09-08 09:09:47.148 UTC [1] LOG: database system is ready to accept connections
🌐
GitHub
github.com › docker-library › postgres › issues › 927
PostgreSQL Database directory appears to contain a database; Skipping initialization · Issue #927 · docker-library/postgres
I get this in the docker logs when doing docker up. /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/01-init.sh PostgreSQL Database directory appears to contain a database; Skipping initialization Looking at docke...
Author   docker-library
🌐
Nextcloud
help.nextcloud.com › ℹ️ support › 📦 appliances (docker, snappy, vm, ncp, aio)
Postgres database failing with errors - 📦 Appliances (Docker, Snappy, VM, NCP, AIO) - Nextcloud community
August 30, 2021 - I’m running lastest version of Nextcloud 21 on docker in unRAID. PostgreSQL Database directory appears to contain a database; Skipping initialization 2021-08-30 11:16:51.006 CEST [1] LOG: starting PostgreSQL 13.4 (Debian 13.4-1.pgdg100+1) on x86_64-pc-linux-gnu, compi...
🌐
GitHub
github.com › supabase › supabase › issues › 36091
Postgres 15.8.1.094 not working locally · Issue #36091 · supabase/supabase
June 1, 2025 - PostgreSQL Database directory appears to contain a database; Skipping initialization pg_ctl: another server might be running; trying to start server anyway waiting for server to start...
Author   supabase
Find elsewhere
🌐
CodePal
codepal.ai › error explainer › postgresql database directory error
PostgreSQL Database Directory Error - CodePal
October 5, 2023 - The error message is generated ... database. It indicates that the database directory already contains a database, so the initialization process is skipped to avoid overwriting or corrupting the existing data....
🌐
Joplin Forum
discourse.joplinapp.org › development
Database error - Development - Joplin Forum
October 18, 2022 - Log of Joplin-db-1 container shows: PostgreSQL Database directory appears to contain a database; Skipping initialization 2022-10-18 04:59:12.704 UTC [1] FATAL: database files are incompatible with server 2022-10-18 04:59:12.704 UTC [1] DETAIL: ...
🌐
GitHub
github.com › orgs › langfuse › discussions › 3924
Postgres version mismatch when upgrading langfuse locally · langfuse · Discussion #3924
db-1 | PostgreSQL Database directory appears to contain a database; Skipping initialization db-1 | db-1 | 2024-10-25 18:25:46.800 UTC [1] FATAL: database files are incompatible with server db-1 | 2024-10-25 18:25:46.800 UTC [1] DETAIL: The data directory was initialized by PostgreSQL version 16, which is not compatible with this version 17.0 (Debian 17.0-1.pgdg120+1).
🌐
Answer Overflow
answeroverflow.com › m › 1379548674400718848
"PostgreSQL Database directory appears to contain a database" - Immich
June 3, 2025 - Hi all, After having WSL issues ... has invalid permissions 2025-06-03 19:49:33.893 UTC [1] DETAIL: Permissions should be u=rwx (0700) or u=rwx,g=rx (0750).``` I haven't messed with any of the db configuration, and tried to ...
🌐
GitHub
github.com › immich-app › immich › discussions › 12550
immich_postgres keeps restarting again and again for bad permissions problem · immich-app/immich · Discussion #12550
September 10, 2024 - The bug I did two thing: update immich to v1.114.0 by the download the latest docker-compose.yaml and other dependent files update docker to v3.34.1 After that, I delete the current immich containe...
Author   immich-app
🌐
GitHub
github.com › immich-app › immich › discussions › 22558
DB Upgrade Error · immich-app/immich · Discussion #22558
October 1, 2025 - If you deployed Immich via the TrueNAS Apps system and later migrate to a standalone Docker/Portainer stack using the official docker-compose example, you can hit a database mismatch. In my case, the old TrueNAS deployment had already created a PostgreSQL 15 data directory, but the compose example I started from used an Immich Postgres image tagged for PostgreSQL 14.
Author   immich-app
🌐
PostgreSQL
postgresql.org › message-id › CAJ6DU3HiJ5FHbqPua19jAD=wLgiXBTjuHfbmv1jCOaNOpB3cCQ@mail.gmail.com
PostgreSQL: PostgreSQL container crash trouble.
March 8, 2021 - --- PostgreSQL Database directory appears to contain a database; Skipping initialization [1] LOG: starting PostgreSQL 12.4 on x86_64-pc-linux-musl, compiled by gcc (Alpine 9.3.0) 9.3.0, 64-bit [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 [1] LOG: listening on IPv6 address "::", port 5432 [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" [20] LOG: database system was shut down at 2021-02-15 21:15:12 UTC [20] LOG: invalid primary checkpoint record [20] PANIC: could not locate a valid checkpoint record [1] LOG: startup process (PID 20) was terminated by signal 6: Aborted [1] LOG: aborting startup due to startup process failure [1] LOG: database system is shut down ---
🌐
Answer Overflow
answeroverflow.com › m › 1374889174431301743
v1.33.0 Upgrade - Postgres unable to copy configuration file: Operation not permitted - Immich
May 21, 2025 - I am attempting to upgrade the Postgres database dedicated to Immich. I am deploying in a Kubernetes environment. When reverting back to the previous Postgres image, everything is working fine. I only changed the image. Here's the full log from the moment the container is started: ``` Using SSD storage cp: cannot create regular file '/etc/postgresql/postgresql.conf': Permission denied chmod: changing permissions of '/var/run/postgresql': Operation not permitted PostgreSQL Database directory appears to contain a database; Skipping initialization postgres: could not access the server configuration file "/etc/postgresql/postgresql.conf": No such file or directory ``` The storage backend is Longhorn, though I do not believe this should be the issue, since the configuration is inside the Docker image.
🌐
Answer Overflow
answeroverflow.com › m › 1318540556435193888
Incompatible PostgreSQL Version - Wasp
December 17, 2024 - After I updated Docker, when I tried to wasp start db I get the error below: PostgreSQL Database directory appears to contain a database; Skipping initialization FATAL: database files are incompatible with server DETAIL: The data directory was initialized by PostgreSQL version 16, which is not compatible with this version 17.2 (Debian 17.2-1.pgdg120+1).
🌐
Answer Overflow
answeroverflow.com › m › 1405090693415702599
Restarting postgres means starting fresh - Immich
August 13, 2025 - 2025-08-13 08:25:02.526 BST [1] ... a database; Skipping initialization the only way i can get it working again is to delete all files in the postgres container folder in appdata but obviously that wipes everything so im back to setting immich up from scratch docker logs ...
🌐
Google Groups
groups.google.com › g › xnat_discussion › c › _BmYUSzPblM › m › DuCZMvBCAQAJ
postgre won't work using docker-compose
PS C:\xnatmaster> docker logs xnatmaster_xnat-db_1 PostgreSQL Database directory appears to contain a database; Skipping initialization FATAL: data directory "/var/lib/postgresql/data" has wrong ownership HINT: The server must be started by the user that owns the data directory.