Database in docker container missing in localhost

when i use $ psql -h localhost -U postgres -p 5432 and check localhost for available databases, i can’t see ny_taxi. when i check container, docker exec -it fd4d3d35db42 psql -U postgres -c "\l" i can see the ny_taxi among the listed dbases. how do i make ny_taxi appear in localhost as well? I use windows 10

@paddyokore I don’t know about postgres. But it seems like you have to map port 5432 in your container to port 5432 on your host.

try:

docker container stop fd4d3d35db42 then
docker run -it -p 5423:5423 fd4d3d35db42 /bin/bash

remember to shut down any running process on port 5432 on your host. or you can try mapping to other ports:

docker run -it -p 5433:5423 fd4d3d35db42 /bin/bash

Article for reference: Networking overview | Docker Docs

1 Like