I'm struggling with a persistent issue when trying to set up my Docker Compose file for a bot and Postgres database. No matter what port I try to forward, the daemon keeps telling me the port is already allocated. I've included my docker-compose setup, which seems straightforward. The error I get during `docker compose up` says that it failed to bind to 0.0.0.0:5432 because the port is already in use. I've tried numerous alternative ports but still encounter the same problem. What am I missing here?
2 Answers
I can't give a specific reason for that error, but using netstat should help clarify what's occupying the port. Also, do you really need to expose that database port to the host? Usually, databases only require access from services within Docker unless there are external applications involved.
You might want to run `sudo netstat -tulpn` to check what's currently using your ports. It's possible that you have Postgres running on your machine already, which would prevent the container from binding to port 5432. If that’s the case, you could try mapping a different host port to 5432 in your container, like 5433 or 5434.
I've tried so many ports, and I'm confident these were free! It's frustrating.

I'm hoping to access it through DBeaver, isn't that a standard way to manage the database?