We are using Postgres in docker. And problem with pg_isready was found.
Please, look:
root@29243fe45836:/# psql -U postgres
psql (11.6 (Debian 11.6-1.pgdg90+1))
Type "help" for help.
postgres=# \l+
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges | Size | Tablespace | Description
-----------+----------+----------+------------+------------+-----------------------+---------+------------+--------------------------------------------
internal | postgres | UTF8 | en_US.utf8 | en_US.utf8 | | 12 MB | pg_default |
postgres | postgres | UTF8 | en_US.utf8 | en_US.utf8 | | 7669 kB | pg_default | default administrative connection database
template0 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +| 7529 kB | pg_default | unmodifiable empty database
| | | | | postgres=CTc/postgres | | |
template1 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +| 7529 kB | pg_default | default template for new databases
| | | | | postgres=CTc/postgres | | |
(4 rows)
postgres=# exit
root@29243fe45836:/# pg_isready -d 123456 -h localhost -p 5432 -U postgres # the DB 123456 doesn't exist
localhost:5432 - accepting connections # but it shows all is good
root@29243fe45836:/# echo $?
0
root@29243fe45836:/# pg_isready -d internal -h localhost -p 5432 -U postgres # the DB internal doesn't exist
localhost:5432 - accepting connections # looks good
root@29243fe45836:/# echo $?
0
The exitcodes of pg_isready if the DB doesn't exist and if exists are the same.
It will be better to exit with non null exitcode if pg_isready can't connect to absent db or using incorrect user.