Have you tried to connect to DB from Ubuntu’s CLI? Have you verified that all docker images are running/ports are exposed and checked their logs?
From postgres image I see that you are not exposing it’s port, which means it is not accessible.
So you should also add:
ports:
- 5432:5432