I have service that is running at port 127.0.0.1:5433 in linux host machine, I want to access this service from the container using host.docker.internal
but i could not.
version: "3"
services:
streamlit:
image: xxx/xxx
build:
context: .
dockerfile: Dockerfile
target: final
ports:
- "8501:8501"
env_file:
- .env
entrypoint: scripts/app_entrypoint.sh
volumes:
- .:/app
extra_hosts:
- "host.docker.internal:host-gateway"
here is the output of ss -ltn
which shows that 127.0.0.1:5433
is LISTENING, but when i try to access this port from inside the container, It says that port is closed. I doubt that this might be issues related to 127.0.0.1
and 0.0.0.0
so i started python http server on port 5433
and bind 0.0.0.0
then i was able to access it from inside the container, but when i start python http server and bind 127.0.0.1
instead i could not access from inside the container.
But i want to access service running on 127.0.0.1
from the container. My collegue on MAC is able to do so but I am using Linux machine and having this issue.
as you can see i have also used extra_hosts
in my docker compose file as per documentation.
extra_hosts:
- "host.docker.internal:host-gateway"
Isn't this sufficient to access service running on 127.0.0.1
? and not only 0.0.0.0