title: Running Android emulator in docker container
body: <p>We are building an app in React Native using wix/Detox for writing e2e tests.</p>
  <p>We are using Docker for doing builds and running tests. Specifically, we're using community react-native-android Docker image.</p>
  <p>I have added fastlane to the image for building / publishing our app and now trying to add an emulator so that we can run tests as well.</p>
  <p>This is our Dockerfile:</p>
  <pre><code># reactnativecommunity/react-native-android:4.0
  FROM reactnativecommunity/react-native-android@sha256:c3ad9b8ed5caac0718b1c1b8f10469eb75b0ac77c86143c94f9616ee46b80b4b
  
  RUN gem install fastlane -NV
  
  RUN sdkmanager --install &quot;system-images;android-31;google_apis;arm64-v8a&quot;
  RUN echo no | avdmanager create avd --name default -k &quot;system-images;android-31;google_apis;arm64-v8a&quot;
  
  </code></pre>
  <p>However, when I run the container and attempt to start the emulator, I get the following:</p>
  <pre><code>root@7b862aa149c8:/# emulator -no-audio -no-boot-anim -no-window -use-system-libs  @default
  emulator: Android emulator version 30.7.5.0 (build_id 7491168) (CL:N/A)
  emulator: INFO: ignore sdcard for arm at api level &gt;= 30
  emulator: feeding guest with passive gps data, in headless mode
  emulator: ERROR: AdbHostServer.cpp:102: Unable to connect to adb daemon on port: 5037
  cannot add library /opt/android/emulator/qemu/linux-x86_64/lib64/vulkan/libvulkan.so: failed
  added library /opt/android/emulator/lib64/vulkan/libvulkan.so
  emulator: INFO: ignore sdcard for arm at api level &gt;= 30
  emulator: INFO: userspace-boot-properties.cpp:242: Sending adb public key [QAAAACG/f/Yfe1MON5LKVoRU+iuzZRCKQTvsqLWcWh8i5ii03oHLY7y7U+0uKSE5x84OrGS0g6G9HTU7Mazh18yhbmPAQociSCfrSRIWg3IAdduFDgYPnY2G3Lj11ZLQoyRt4+xXO7zVcUPtwERpgpYQXEN5KkkEZBUxxWvrejENPAffPp4DHFqJf63sAUPh9qo6cwfSMylnl7RTBicxZ+tuDwrxA1JgcvklAs38E9gzxjNDed+1VibNUjzCtRl4DnPPmIk1OqhvjU0xZV//YXDrdhb++jQOpcKAzkCvVks4RUjJ1okytnmDfh+YUH4thQYuqNdEBnGM4wz8cPQH0YjO1SsK2sOrD0VJaGjSDAwsjne2QCFy5ET+HOUcMNKCaC60MAcCgWXLm8MdoaVLgjoG0jbUEkr/BJ2hpN7/p+qi8qMSg3Vv2M/4kdHmIEzDpJTd8TFD1bbrRjdUIheDzE1b00SKhQzDJ39sQim31IqWGuRIJ4Cb39VaHCFK6ZwZPpG9KKLSV1ww5KCKVgSsJ5zaAvhagCjXXXVrtl40v72zYq/c0BtUG4LhLixtz/zuT1WFKq8HoGFkJBvw5fBVqcvOn6yN7xI3DAuzAlQcHPyRQdHm72+//KimCVHnkxlL3hpRMir06QhMk2DsKTntXjbYuhCCn0aetEUUpai6gl1NuCbv92QlDgEAAQA= @unknown]
  emulator: INFO: GrpcServices.cpp:315: Started GRPC server at 127.0.0.1:8554, security: Local
  WARNING. Using fallback path for the emulator registration directory.
  emulator: INFO: EmulatorAdvertisement.cpp:93: Advertising in: /root/.android/avd/running/pid_9.ini
  qemu-system-aarch64-headless: PCI bus not available for hda
  saving arm snapshot.... !!!
  
  saving done.... !!!
  
  root@7b862aa149c8:/#
  </code></pre>