I am trying to run a react native docker container on vs code. I am able to run my code. However, the container is not able to detect the android emulator running on my host machine.
I followed along in this tutorial course:
https://code.visualstudio.com/docs/remote/containers & https://github.com/microsoft/vscode-react-native
On running
npx react-native run-android however, I get an error message that my emulator is not running. error Failed to install the app. Make sure you have an Android emulator running or a device connected. Run CLI with --verbose flag for more details. Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
My devcontainer.json:-
{
"name": "React Native Android Container",
// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerFile": "Dockerfile",
"runArgs": [
"--privileged", // give all capabilities to a container, in other words, the container can then do almost everything that the host can do
"--net",
"host", // forwarding all host machine ports
"-v",
"/dev/bus/usb:/dev/bus/usb" // mount connected USB devices to a container
],
"settings": {
// This will ignore your local shell user setting for Linux since shells like zsh are typically
// not in base container images. You can also update this to an specific shell to ensure VS Code
// uses the right one for terminals and tasks. For example, /bin/bash (or /bin/ash for Alpine).
"terminal.integrated.shell.linux": null
},
// Add the IDs of extensions you want to be installed when the container is created in the array below.
"extensions": ["msjsdiag.vscode-react-native"]
}
the runArgs "host" is supposed to forward all ports. I think I need a similar argument in the reverse direction?