I have a python flask application running inside a docker container. And I am using Test-DbaNetworkLatency
to test the network latency between my application and SQL Server (running on premise). I found that the network latency is very slow when it runs from a docker container but it is very fast when I run on a Mac host. The docker container is based on ubuntu
and I installed powershell
on it. Test-DbaNetworkLatency
is running from powershell. I also installed powershell
on my local Mac OS.
The result from my local is:
ExecutionCount : 1
Total : 220.91 ms
Average : 220.91 ms
ExecuteOnlyTotal : 154.21 ms
ExecuteOnlyAverage : 154.21 ms
NetworkOnlyTotal : 66.69 ms
but the result from the docker container is:
ExecutionCount : 1
Total : 1.23 s
Average : 1.23 s
ExecuteOnlyTotal : 282.52 ms
ExecuteOnlyAverage : 282.52 ms
NetworkOnlyTotal : 946.88 ms
You can see that there is a big network latency when it runs from docker. Is there anything wrong related to docker?
There is not much different if I ping the instance from container and local. But I do see performance different when a sql query is sent from container and local. That's why I need Test-DbaNetworkLatency
to test network latency.
After some testing I found if I put the command Test-DbaNetworkLatency
inside pwsh -Command "Test-DbaNetworkLatency ... "
it will be very slow. But if I run pwsh
to switch to powershell command then it runs as fast as my local. But how can I define a dockerfile to let the container initialize a powershell
let me specify a powershell
script as ENTRYPOINT?