Both Sonarqube and Postgres database should be same network in order communicate with each other. First create docker network using the following commands
Delete existing docker network and create new docker network sonarqube
docker network rm sonarqube_network
docker network create sonarqube_network