**note that hostname of jdbc connection url is postgreDB(not localhost), due to 'localhost' points to the container itself which execute spark application, not the postgresql server. it's due to the characteristic of docker compose, it automatically places all services on the same network.
spark-postgresql connection
.config('spark.jars.packages', '/opt/spark/jars/postgresql-42.7.3.jar')\
**note that hostname of jdbc connection url is postgreDB(not localhost), due to 'localhost' points to the container itself which execute spark application, not the postgresql server. it's due to the characteristic of docker compose, it automatically places all services on the same network.