androiddockerdocker-machineappium-android

Connect external emulator from docker container


I have build container that contains everything we need for testing our app, expect the emulator, I want to keep them locally in my machine.

I run the container using this command

docker run -d -p 4725:4725 -p 4723:4723 -p 5037:5037 -p 5555:5555 --privileged  -v /Users/moradk/Root/automation/apk/:/root/tmp/  --name appium-offical appium-offical shell

when I run shell command inside the container:

adb devices

I get no devices where found.

otherwise I have connoted device to my local machine (NOT TO THE DOCKER), when I run add devices in my local machine (Mac), I get the device name

How can I connect the docker to the local device, I try to run:

adb connect 0.0.0.0:5555

to connect my local device to the docker, but does not work,

Any suggestions please ?

Thank you all.


Solution

  • You should remove "-p 5037:5037" in docker run command

    Then make a tunnel in the docker container:

    ssh -L 6037:localhost:5037 -N -g username@host_ip_address -f
    

    You can access host adb via:

    adb -H 127.0.0.1 -P 6037 devices
    

    You can also use the default port 5037 in ssh tunnel, that's work for me.