Docker dynamic expose port via host mode, but the ports are not accessible from external

737 Views Asked by At

I'm trying to run a frp in a container, which needs to listen on dynamic ports. That means the frp may open additional ports in running time.

My operations step by step

  1. On my remote VPS, I use the following command to start a frp server. Note that I use host mode which means, by Docker doc, that all the opened port of frp is accessible from host and external machines.
docker run -d \
--network=host \
-v /etc/frp:/etc/frp/:ro \
--name frps \
--rm \
290007431/frps:v0

Here is the program inside the container, which shows that port 7500 and 9000 is available beginning.

  1. On my Mac (Big Sur) and Raspberry Pi (Debian 10), I try to visit the dashboard web via port 7500, which results a failure. So I use namp to scan the port. Here is the result result. It shows that the 7500 and 9000 are unaccessible from the client endpoint (Mac and Raspberry Pi).

  2. As things goes out of my mind, I return back to my VPS to check whether the port is actually exposed or not. I use netstat -nlptu command, here is the result which shows that the VPS is listening on 7500 and 9000 portresult.

Isn't it very odd?

1

There are 1 best solutions below

0
Xu Zhenxing On

Finally!!! I found the reason why I can not access my VPS from external. That is the VPS Provider has the default firewall, which run outside of the VPS. I login into the VPS Provider console and configure it. What a foolish story