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 OverflowIf, 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!
According to the documentation of postgres docker image you did everything correct.
If you would like to do additional initialization in an image derived from this one, add one or more *.sql, *.sql.gz, or *.sh scripts under /docker-entrypoint-initdb.d (creating the directory if necessary). After the entrypoint calls initdb to create the default postgres user and database, it will run any *.sql files, run any executable *.sh scripts, and source any non-executable *.sh scripts found in that directory to do further initialization before starting the service.
But, there is a catch which I think you missed based on log that you posted above.
Warning: scripts in /docker-entrypoint-initdb.d are only run if you start the container with a data directory that is empty; any pre-existing database will be left untouched on container startup.
So, I would give it a try to empty database_data directory and run again docker-compose up.
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
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.