Over the last lectures,
we learned that Docker has some pretty nice features,
when it comes to requests leaving one container
and going to the host machine
or going to another container.
Specifically, we can use host docker internal
as an address to target the host machine,
in case some services running there.
And you just learned about container networks
and that when you use them
and multiple containers are in the same network,
you can actually use the name of a container as a domain,
as an address, and Docker will automatically resolve
the IP addresses.
That's a cool feature.
I just want to ensure that we all understand it correctly.
Docker will not, important, not go ahead
and start replacing your source code under the hood.
That is not what it's doing.
It's not replacing your source code.
So it will not read your source code,
see a container name and plug in the IP address
of that container into your code.
That would be way too complex
and it's not what it's doing.
Instead Docker owns the environment
in which your application runs.
And if your application sends an HTTP request
or a MongoDB request or any other kind
of request that leaves the container,
then Docker is aware of that.
And it's that point of time where Docker
then is able to resolve the address,
or the container name or host Docker internal
and replace it with the actual IP address,
since it is aware of the surrounding containers
and the host machine.
So it's only when a request leaves the container.
If a request does not leave a container,
or if a request is generated somewhere else,
for example, in the browser.
If users are visiting your web app and JavaScript code
is running in their browser
and a request is sent from there,
then Docker is not doing anything
because it's not replacing the source code.
That's just important that we all understand
how that auto IP resolving feature
actually works under the hood.