I have hosted an apllication in docker container using windows docker desktop. i can see its getting hosted inside the container rather than in hosts localhost.
tried multiple solution available over internet but nothing worked out.
1.Used -p to publish to redirect the port.
2.Used --network="host" in your docker run command
3.tried export DOCKER_HOST_IP=$(route -n | awk ‘/UG[ \t]/{print $2}’)
root@0be0501ec1aa:/streetscape# netstat -ap
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 localhost:http-alt 0.0.0.0:* LISTEN 677/node
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node PID/Program name Path
root@0be0501ec1aa:/streetscape# curl http://localhost:8080
<!doctype html>
You want to publish the exposed port to the outside world. Use a flag on the run command -p 8080:8080 to link the container’s port 8080 to the host port 8080. It goes in this order -p [HOST]:[CONTAINER]. You can add multiple -p options and the host port needs to not be in use by something else. If you are orchestrating multiple containers with docker-compose.yml file then add the follow.
ports:
- “8080:8080”
I have already tried these 3 options and its not working
1.Used -p to publish to redirect the port.
2.Used --network="host" in your docker run command
3.tried export DOCKER_HOST_IP=$(route -n | awk ‘/UG[ \t]/{print $2}’)