I am using this docker-compose to spin up a postgres instance on my laptop. It works fine when I connect it as localhost. However, I would like to connect to it from a different laptop but i'm not able to. In the postgresql.conf file, the listening address is set to * already and I also added the this line host all all 0.0.0.0/0 md5
to pg_hba.conf. When I connect to it locally with DBeaver, it only works with localhost or 0.0.0.0 as host but doesn't work when I change it to the container IP. What am I missing here?
docker-compose.yml
services:
database:
image: postgres
ports:
- "5432:5432"
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: mydb
user: postgres
volumes:
- pgdata:/var/lib/postgresql/data
volumes:
pgdata: