google / android-emulator-container-scripts

1.82k stars 256 forks source link

Can't run android emulator inside another docker (dind) container - Address not available #329

Closed madim closed 1 year ago

madim commented 1 year ago

Environment: Gitlab CI with Gitlab Runners. KMV is available. I'm running android-emulator docker container inside another docker container. Here is Dockerfile of hosting container.

I was able to run docker and launch android emulator. I'm sure of it because I see emulator logs. But I still can't connect to it through adb connect localhost:5555 from hosting container. I'm assuming that's because I running it as Docker in Docker:

+ adb connect localhost:5555
Connecting to forwarded adb port.
* daemon not running; starting now at tcp:5037
* daemon started successfully
Address not available

How to resolve Address not available?

madim commented 1 year ago

I was able to resolve issue. Turned out that localhost is not available when running in dind mode. So instead of running adb connect localhost:5555, I needed to run adb connect 172.17.0.1:5555.

Here are useful links:

  1. https://stackoverflow.com/q/24319662/5222156
  2. https://stackoverflow.com/a/48547074/5222156