an small problem with docker.
An net core container is not able to connect to an Postgres container with docker compose.
A connection from host to the Postgres container works well with "Host= localhost;Port=5432;.. .."
But an netcore Container together with Postgres did not work, database is not reachable:
In the Net core app "Host=psql;Port=5432;.. .."
Dockerfile:
version: '3.1'
services:
psql:
build:
context: .
dockerfile: DockerfileDb
restart: always
environment:
POSTGRES_PASSWORD: Start!123
ports:
- "5432:5432"
container_name: psql
app:
build:
context: .
dockerfile: DockerfileApp
ports:
- "80:80"
# - "443:443"
container_name: watchdog
links:
- psql
depends_on:
- psql
restart: always
Also with an configured network :
version: '3.1'
services:
psql:
build:
context: .
dockerfile: DockerfileDb
restart: always
environment:
POSTGRES_PASSWORD: Start!123
ports:
- "5432:5432"
container_name: psql
networks:
- local
app:
build:
context: .
dockerfile: DockerfileApp
ports:
- "80:80"
# - "443:443"
container_name: watchdog
links:
- psql
depends_on:
- psql
restart: always
networks:
- local
networks:
local:
driver: bridge