I have the following definition of docker-compose file with postgres image that I want to run and connect to it from hosting machine of my PC, but I'm getting Connection Refused localhost:5432
all the time. I realize that container has to be run on host network driver, but network mode doesn't solve this problem. What I'm doing wrong?
I run this with docker-compose -f [file] up
on Windows 10 with Docker for Desktop
version: '3.7'
services:
database:
image: postgres:10.6
restart: always
ports:
- "5432:5432"
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=p0stgr@s
- POSTGRES_DB=eagle_eye_local
network_mode: host
When I run the same container with the following command it works:
docker container run --name postgres10.6 -e POSTGRES_PASSWORD=p0stgr@s -e POSTGRES_USER=postgres -e POSTGRES_DB=eagle_eye_local -p 5432:5432 postgres:10.6