I’m trying to build a flask chat app but facing following issue (on windows)
sending post and get requests works fine locally through
127.0.0.1 - - [26/Oct/2024 16:54:56] “GET / HTTP/1.1” 200 -
127.0.0.1 - - [26/Oct/2024 16:55:17] “POST /send-message HTTP/1.1” 200 -
but as soon as the app is made into a docker container
the app opens through localhost:5000 and 127.0.0.1:5000 but port 172.17.0.1:5000 refuses to connect.
when request is run through localhost:5000 or 127.0.0.1:5000 the docker app automatically routes it through
172.17.0.1 - - [26/Oct/2024 16:54:56] “GET / HTTP/1.1” 200 -
172.17.0.1 - - [26/Oct/2024 16:55:17] “POST /send-message HTTP/1.1” 200 -
which does not get the response.
is there a way to get the 172.17.0.1 to connect or a way to route the post and get through 127.0.0.1 how to change the docker default
Please, format your post according to the following guide: How to format your forum posts
In short: please, use </> button to share codes, terminal outputs, error messages or anything that can contain special characters which would be interpreted by the MarkDown filter. Use the preview feature to make sure your text is formatted as you would expect it and check your post after you have sent it so you can still fix it.
Example code block:
```
services:
service1:
image: image1
```
After fixing your post, please send a new comment so people are notified about the fixed content.
The indentation of your code is still wrong. But regarding the IP address, since the container is in a virtual machine, you can’t access the container IP. I wrote about Dcoker networking here
and I refer to it on other pages of the original source of that tutorial too
Note
Since Docker Desktop runs containers in a virtual machine, Container IP addresses are not available from the host. You can run curl in a container on host network:
docker run --rm -it --net host curlimages/curl $IP:8080
Besides the accidentally included “Preformatted text” string, I don’t see any difference. Of course the source IP could be different when you run it from different environments. I never used the experimental Docker Desktop terminal