2021年11月22日 星期一

solve: docker network can container access the localhost by host mode

 1.  

Lastly, under Linux you can run your container in the host network namespace by setting --net=host; in this case localhost on your host is the same as localhost inside the container, so containerized service will act like non-containerized services and will be accessible without any additional configuration.


docker-compose-running-containers-in-nethost

how-to-access-host-port-from-docker-container

2. other

iptables -A INPUT -i docker0 -j ACCEPT


3. ipforward

作業系統擁有 IP轉發(英語:IP forwarding功能,意味著該系統能接收從接口傳送進來的 網絡數據包(英語:network packets),如果識別到該數據包不用於該系統自身,那麼系統將會將該網絡數據包傳送到另外一個網絡去,用恰當地方式轉發該數據包。[1]

一個典型的場景是需要去搭建一個路由器以連接兩個不同網絡。


4. more discuss

https://ithelp.ithome.com.tw/articles/10206725

沒有留言:

張貼留言