Metro bundler with Expo dockerized app is not working Metro bundler with Expo dockerized app is not working docker docker

Metro bundler with Expo dockerized app is not working


Makes sense. Expo DevTools tells you it is running on localhost in your container.

This means that in your container the Expo DevTools are only available to localhost. Which in turn is only available from within the container itself. No port exposure will help you there. You need to set your port binding in a way that allows outside access. e.g. via the IP of the container in order to allow an expose statement to work.

In short, add the EXPO_DEVTOOLS_LISTEN_ADDRESS=0.0.0.0 environment variable like this

version: '3.7' # Specify docker-compose versionservices:   expo: # Name of the frontend service      container_name: expo-prestadores      build: ./ # Specify the directory of the Dockerfile      ports:         - 19000:19000 # Specify port-forwarding         - 19001:19001         - 19002:19002      volumes: # Mount host path in the container         - ./:/usr/src/app         - /usr/src/app/node_modules      environment:         - EXPO_DEVTOOLS_LISTEN_ADDRESS=0.0.0.0 

to your docker-compose.yml and you should be fine.


I might be a little too late for this but I've come up with a workaround here, once you've implemented the solution given by @ckaserer you can log on to http://0.0.0.0:19002 and select Tunnel instead of LAN in the connection section just as shown below and run your application on Expo Go App and it'd be fineenter image description here


To fix the black background screen in the browser as mentioned in previous responses, you must add the REACT_NATIVE_PACKAGER_HOSTNAME environment variable and set it to your computer's local IP address. Then instead of navigating to localhost:19002 or 0.0.0.0:19002 for the Expo Developer Tools, navigate to <<HOST LOCAL IP>>:19002 (replacing with your respective IP, of course), and you should see the DevTools working. The QR code on this page should load your app on ExpoGo at the address <<HOST LOCAL IP>>:19000.

Your docker-compose.yml should now look like this:

version: '3.7' # Specify docker-compose versionservices:   expo: # Name of the frontend service      container_name: expo-prestadores      build: ./ # Specify the directory of the Dockerfile      ports:         - 19000:19000 # Specify port-forwarding         - 19001:19001         - 19002:19002      volumes: # Mount host path in the container         - ./:/usr/src/app         - /usr/src/app/node_modules      environment:         - EXPO_DEVTOOLS_LISTEN_ADDRESS=0.0.0.0          - REACT_NATIVE_PACKAGER_HOSTNAME=<<HOST LOCAL IP>>>