I wanted to run postgres database in docker container. I pulled the newest image of postgres:
docker pull postgres
And started container out of it:
docker run --rm --name pg-docker -e POSTGRES_PASSWORD=docker -d -p 5432:5432 postgres
After that I tried to access the postgres:
psql -h localhost -U postgres -d postgres
And connection failed:
psql: error: could not connect to server: could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432?
could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?
I don't understand why?
[EDIT] I tried it on Windows 10 Pro with Docker Toolbox and it fails, however on Ubuntu 18.04 works fine.