[英]How do you pass in host IP address to docker container
I'm setting up Expo docker image in Mac environment and I need to set REACT_NATIVE_PACKAGER_HOSTNAME with my host ip address, so that Expo Go app can hit that ip from my phone.我正在 Mac 环境中设置 Expo docker 映像,我需要使用我的主机 IP 地址设置 REACT_NATIVE_PACKAGER_HOSTNAME,以便 Expo Go 应用程序可以从我的手机中访问该 IP。 Since my host has dynamic ip, I need to update REACT_NATIVE_PACKAGER_HOSTNAME with a newly assigned ip whenever my host ip changes, and then restart my container.
由于我的主机具有动态 ip,因此每当我的主机 ip 更改时,我需要使用新分配的 ip 更新 REACT_NATIVE_PACKAGER_HOSTNAME,然后重新启动我的容器。 This is not convenient at all and I want to eliminate that manual update process.
这一点都不方便,我想消除手动更新过程。 I tried using host.docker.internal and docker.for.mac.host.internal as value but they do not resolve to ip address.
我尝试使用 host.docker.internal 和 docker.for.mac.host.internal 作为值,但它们不能解析为 IP 地址。 Am I missing something here?
我在这里错过了什么吗? I'm setting REACT_NATIVE_PACKAGER_HOSTNAME inside .env file if that matters.
如果这很重要,我将在 .env 文件中设置 REACT_NATIVE_PACKAGER_HOSTNAME 。
Docker-Compose version: '3.8' Docker-Compose 版本:'3.8'
when you pass --network host to container when you just run it, the dynamic IP address of your host will appear in the container.当你刚刚运行它时将--network host传递给容器,你的主机的动态 IP 地址将出现在容器中。 right?
正确的?
the correct answer is : https://stackoverflow.com/a/39549309/4170685正确答案是: https ://stackoverflow.com/a/39549309/4170685
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.