'Docker postgres container exits with error code 1 without error message

When I try to build and run my postgres container, it immediately exits with error code 1. This is happening since Docker updated to version 4.7.0. I looked at the logs and there is no error message anywhere:

Creating football_marketplace-development_postgres_run ... done
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Etc/UTC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    pg_ctl -D /var/lib/postgresql/data -l logfile start

waiting for server to start....2022-04-10 03:22:59.257 UTC [35] LOG:  starting PostgreSQL 14.2 (Debian 14.2-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
2022-04-10 03:22:59.258 UTC [35] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2022-04-10 03:22:59.262 UTC [36] LOG:  database system was shut down at 2022-04-10 03:22:59 UTC
2022-04-10 03:22:59.265 UTC [35] LOG:  database system is ready to accept connections
 done
server started
CREATE DATABASE


/usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/marketplace.sql
The input is a PostgreSQL custom-format dump.
Use the pg_restore command-line client to restore this dump to a database.

As we can see, there is no error message and the output looks normal just like when it worked before the update. But for some reason it just exits.

The even weirder part about this is, that when I restart the container after it exited, it doesn't exit anymore and works perfectly. But I would like to have it not exit so that I dont always have to restart it. The ports are freed.

I already looked at similar threads on here, but all of them are associated with some error message.

This is my Dockerfile:

FROM postgres

ADD ./marketplace.sql /docker-entrypoint-initdb.d
USER postgres


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source