React Native development environment Docker image
Dockerized React Native development environment for VS Code remote development and USB connected physical Android device. Works without Android Studio.
Features:
- based on Ubuntu LTS
- Android SDK version: see repository tags
- Node.js version: v14 LTS
Use docker.sh script in project directory.
- Build Docker image: execute
./docker.sh build. - Run Docker image: execute
./docker.sh run.
Docker container is not removed after exiting the application. To start the container again, execute ./docker.sh start.
- Install VS Code extension Remote - Containers.
- Optional: Install VS Code extension React Native Tools.
- Enable
Developer modeandUSB debuggingoption on your device. - Plug your device into your computer.
- Select
PTPorMTPconnection on your device.PTPworked for me in most cases. - In VS Code, run
Attach to Running Containercommand. - Run
adb devicescommand in attached VS Code terminal and verify the output. - If prompted on your device, authorize your computer to access the device.
- workspace: share files between the host and containerized app
You can initialize new React Native applications inside the workspace directory to make them persistent on host machine.
- Connect your Android device as described above.
- Open attached VS Code terminal.
cd $HOME/workspacefor persistent code base.react-native init appNamecd $HOME/workspace/appName && react-native start- Open new remote terminal tab in attached VS Code.
cd $HOME/workspace/appName && react-native run-android
Mount directories must be writable by group with id 1000. Execute these commands in project root directory:
chown -R $(id -u):1000 "${PWD}"/workspace
chmod -R g+w "${PWD}"/workspaceTry running adb kill-server command in container and reconnect the device
Run react-native start in a separate terminal and then run react-native run-android. Source