When I’m having trouble with network configuration on Docker, I sometimes use network_mode: "host" in the compose file to bypass Docker’s networking layer. That way, you can figure out if the problem actually is related to your port config, or if the issue is somewhere else.
Unrelated example for demonstration purposes:
compose.yaml
---
services:
db:
image: "docker.io/postgres:16"
restart: "always"
environment:
POSTGRES_DB: "${POSTGRES_DB:?}"
POSTGRES_USER: "${POSTGRES_USER:-postgres}"
POSTGRES_PASSWORD: "${POSTGRES_PASSWORD:-postgres}"
network_mode: "host"
volumes:
- "postgres:/var/lib/postgresql/data"
volumes:
postgres:






















