Skip to content Skip to sidebar Skip to footer

How Do I Connect The Local Sql Server Database For The Asp.net Core Application Running Inside Either Local Docker Or Kubernetes?

I created an ASP.NET Core Web API using VS2017. After that I enabled the Docker support for my application. Next, I was implemented the EF Core feature. After that I tested applic

Solution 1:

You need to give the host's IP. In linux, you can use "host.docker.internal" hostname to connect to the host machine. It is supposedly working in Windows, however it has many, many, far too many problems in Windows.

If this hostname does not work for you, you have 2 IP addresses. One is the docker's gateway, that should start with 10...* or 172...* depending on how you set it up. Normally to learn this one, use docker inspect <container> and you can see the default gateway in the network section. However, Kubernetes might change these and it might be providing a better means to access the host. I did not use Kubernetes, so I don't know.

The other option is to use the IP address of the host, assigned by your network using DHCP. It should normally start with 192.168...

Your containers should be able to access applications on your host using these IP addresses. If the problem persists, turn off your firewall, and try pinging from inside the containers.

Post a Comment for "How Do I Connect The Local Sql Server Database For The Asp.net Core Application Running Inside Either Local Docker Or Kubernetes?"