dockernetwork-programmingcontainersadbandroid-uiautomator

Docker container fail to connect to UiAutomator2 server created by host ADB


I want to containerise my test automation. In my Dockerfile I have set ADB server addess to ENV ANDROID_ADB_SERVER_ADDRESS "host.docker.internal". Therefore, when adb is abl eto list connected devices using adb devices. But the issue here is host ADB will create UiAutomator2 on my host which will give Connection Refused on y container. Any idea how to resolve this?


Solution

  • In docker compose using

        network_mode: host
        hostname: localhost
    

    will solve the issue to connect to ADB. But it will fail connecting to 8200 which is the UiAutomator service. I will post another question regarding this.