I spinup postgres container and its data path /var/lib/postgresql/data is mapped to my local using volumes. As soon as container is up and database is setup the local path populates with all db data. I need to some how check programatically (using Python) if local location is proper postgres db data. This is needed if I need to create tables or not. I create if local directory is blank or invalid postgres data and I don't if it is valid. The reason I am trying to achieve this is if I want to hook up local db created due to postgers_container_1 to postgres_container_2
If the file /var/lib/postgresql/data/PG_VERSION exists, then it's probably a valid data directory. This is the first thing Postgres will check when you try to start the server.
Of course, there are many, many other things required to make it a valid data directory - too many to check by yourself. If you need to be 100% sure, the only practical way is to start the Postgres server and try to connect to it.
How to check if directory is valid Postgres database