0

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'

KMC
  • 1,677
  • 3
  • 26
  • 55
  • #1 Who needs REACT_NATIVE_PACKAGER_HOSTNAME? #2 Is required at build or at run? – JRichardsz May 11 '22 at 04:56
  • It's used by bundler to configure bundle with that IP during bundling process. Otherwise, bundler will just use docker container's ip which is not accessible from phone. – KMC May 11 '22 at 11:17
  • So, according to your comment, this variable is required at docker build stage, not at docker run. Am I correct? Could you share us the stack technologies? – JRichardsz May 11 '22 at 14:19

1 Answers1

0

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

  • I've tried something equivalent in compose file ( network_mode: "host" ) and i get " "host" network_mode is incompatible with port_bindings". Looks like this option can't be used with port binding. Any thoughts? – KMC May 11 '22 at 11:40
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 12 '22 at 17:18
  • @KMC that's right , follow : https://stackoverflow.com/a/39549309/4170685 – TheGreateJ May 25 '22 at 04:09