I am currently learning the fundamentals of docker. I have learnt that when a container needs to connect to the host machine (let's say I have a local mysql database), instead of using localhost
as the domain, it has to use host.docker.internal
as the domain.
So instead of something like this:
createConnection(
host: "localhost",
...
)
I would do this:
createConnection(
host: "host.docker.internal",
...
)
I think I understand why this is the case, but I just wanted to clarify why docker doesn't understand what localhost
means, and why it has to be replaced with host.docker.internal
.
Thanks in advance.