Reputation: 2051
I have BrowserMobProxy
realization in the project. This logic uses the IP address for Proxy connection and test UI web-service (Proxy used for request/response statistic saving). All worked fine before, but we restart docker and the IP address for the proxy was changed. Now I need to found a new IP address for the proxy.
Code where IP address used
public static void startProxyServer(String address) {//address = "172.17.0.2"
if (browserMobProxy.isStarted()) {
browserMobProxy.stop();
}
try {
browserMobProxy.start(9090, Inet4Address.getByName(address)); // {1}
useExclusivePort = browserMobProxy.getPort();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
After docker was restarting the project began fails on the line {1}
.
I started the search for new IP on the server. Unfortunately, I can't use ifconfig
command from the docker image since this command does not install there. So I determined the address from the server in the following way:
After I use IP 172.17.0.2 the code works well and I hoped I resolved this issue, but as it turned out I lost connection with this proxy - on the UI I got the following result:
So I totally confused:
#Question:
How do I need to found the correct IP that I can use for a proxy connection?
Upvotes: 2
Views: 392
Reputation: 1055
there are other commands with which you can find which ip your server is running on. check if you have access to any of the following
first you can try
netstat -an
which will give you all IPs your server is listening to along with what ports, and what IPs are connected on it along with the ports
if this doesn't work try this https://dev.to/trexinc/netstat-without-netstat-inside-containers-9ak
then try
ip addr
which will give you a similar output as ifconfig
and last you can try with
docker inspect -f '{{ .NetworkSettings.IPAddress }}' containerID
which will give you the network interfaces of your docker
Upvotes: 2