[英]How do I pass the host's IP address to my container in Docker
我的計算機上有多個NIC,因此有多個可外部路由的IP地址。
當我啟動容器時,我想讓容器的虛擬eth0具有我公開可見的IP地址之一的IP地址
這是因為我的每個應用程序都查詢其本地IP並通過專有協議將其傳遞給外部,因此所有的iptables技巧都不會工作
我該怎么做呢?
我不確定這是不是一個好習慣,但你可以在啟動容器時傳遞--net
選項:
docker run --net=host ...
從man docker run
:
--net="bridge"
Set the Network mode for the container
'bridge': creates a new network stack for the container on the docker bridge
'none': no networking for this container
'container:': reuses another container network stack
'host': use the host network stack inside the container. Note: the host mode gives the container full access to local system services such as D-bus and is therefore considered insecure.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.