[英]windows run docker with --network=host and access with 127.0.0.1
[英]Docker - access to host network and docker network
我有一个 docker 容器,我想给它--network=host
AND --network=postgres
。 我需要连接到主机网络才能将主机数据狗服务器 (UDP) 和postgres
网络用于其数据库。
尝试在docker: conflicting options: cannot attach both user-defined and non-user-defined network-modes.
.
知道处理这个问题的正确方法是什么吗?
您可以使用容器内的主机 IP 地址向主机发送请求。
但是,更好的解决方案是使用--add-host=host.docker.internal:host-gateway
或
extra_hosts:
- host.docker.internal:host-gateway
其中host.docker.internal
是 docker 容器内的主机网络的主机名。 此名称当然可以根据您的喜好更改。
信用: https ://medium.com/@TimvanBaarsen/how-to-connect-to-the-docker-host-from-inside-a-docker-container-112b4c71bc66
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.