I can’t reproduce the problem. If I do what you describe, it Works For Me. Presumably there’s some other sort of customisation you’ve applied, but not mentioned, that’s causing the problem.
Incidentally, since you’re running on the same machine, you don’t have to expose the port, you can just connect to the Docker-internal IP (172.17.0.<X>
) on port 5432 and it should work.