![]() ![]() One of the core things Docker does is to give each container its own separate network space. If you make an outbound connection to 127.0.0.1 from a container it will return to the same container if you bind a server to 127.0.0.1 it will not accept connections from outside. ![]() In Docker 127.0.0.1 almost always means “this container”, not “this machine”. You must set a container’s main process to bind to the special 0.0.0.0 “all interfaces” address, or it will be unreachable from outside the container. http: error: ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=8000): Max retries exceeded with url: /api/urls (Caused by NewConnectionError(': Failed to establish a new connection: Connection refused')) while doing GET request to URL: Here is the http error that I received in case of 127.0.0.1. RUN pip install -no-cache-dir -r requirements.txtĬMD # doesn't work I knew it.īut when I run the app at my localmachine (host: 127.0.0.0:8000) everything was working and the app could do the connection to the real website but in case of docker it stopped to work. I read some articles about 0.0.0.0 and it's like a 'generic' or 'placeholder' port that allows to use the OC default port.ġ27.0.0.1 is like a host that redirects the request to the current machine. So my question is: Why it behaves like that? What is the difference in this particular case? I just want to understand it. my app wasn't working because of the impossibility to do an external connection to the website.īut when I set the port for my server: 0.0.0.0:8000 it started to work. So when I set in the Docker file the address of my django server that should work in the container - 127.0.0.1:8000. I'm working with docker and trying to dockerize a simple django application that does an external http connect to a web page (real website) ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |