DEV Community

Cover image for Running a dockerized React Native application
Taher Lunavadi
Taher Lunavadi

Posted on

Running a dockerized React Native application

Why do we run a React Native application in a docker container?

At times setting up React Native dev environment could be a prick in the spine, hence docker solves all those issues and let's us build a React Native application in a container facilitating testing the application as well.

In this tutorial, we'll orchestrate a docker container with a bare minimum React Native application with Expo managed workflow.

We'll use https://github.com/taher07/dockerized-react-native to complete our task

pre-requisites

  • docker
  • docker-compose (which usually comes along with docker but if it's not the case then yeah)

steps

  • clone the repository using git clone https://github.com/taher07/dockerized-react-native.git my-app
  • Navigate to the repository and run rm -rf .git/
  • Run docker-compose up, you gotta give it some time
  • Your React Native application would have probably been running by now, go to http://0.0.0.0:19002 from your browser and it would render dev tools in your browser
  • Under the connection section click on Tunnel and you can now run your expo managed app from the Expo Go app on Android or iOS devices (It has been shown below)

Metro

  • Now let's get into bash specific to docker container as
    • Run docker ps and copy the container id
    • Run docker exec -it <container_id> bash
  • You're all set to start developing your dockerized React Native application

Any further discussion on this thread are welcome below!

Top comments (1)

Collapse
 
zarandonlautaro profile image
Lautaro Zarandón

Thanks for your post ! This is amazing.
I'v a question, do you know how to make works a react native app in docker but without expo ?
Sorry I'm newbie in docker