简体   繁体   中英

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. 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. 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. Am I missing something here? I'm setting REACT_NATIVE_PACKAGER_HOSTNAME inside .env file if that matters.

Docker-Compose version: '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. right?

the correct answer is : https://stackoverflow.com/a/39549309/4170685

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM