Unable to run psql inside a postgres container

You are causing the problems yourself. Can you please try the exact command I provided early, without replacing any parts? You do make the entrypoint script skip database start because you add “bash” as an argument to the container. Don’t do that.

me@swarm1:~$ docker run -e POSTGRES_PASSWORD=postgres -it postgres bash
root@cff45e74daba:/#

vs.

me@swarm1:~$ docker run -e POSTGRES_PASSWORD=postgres -it postgres
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

You should always first try exactly what the Dockerhub descriptions say, before trying to modify somethine on the run command…

btw. I removed -d for faster troubleshooting, you should add it in your final command again.