1

I'm trying to debug an app (or simply inspect pages in the Chrome browser) on my mobile device and I'm trying to use docker containers for housing adb. Everything goes well while starting up the adb server in the container and I even get to list my device with adb devices, but once I go to chrome://inspect/#devices (on my local machine), I don't get to see my device listed over there.

This is how I'm running the docker container:

docker run --rm -it --privileged -v /dev/bus/usb:/dev/bus/usb -p 5037:5037 beevelop/ionic bash

What am I missing here? I tried exposing some ports like 9222 and 9229 (-p 9222:9222 -p 9229:9229) but it had no impact on results. I've also already installed usbutils on the container.

2
  • 2
    When dealing with external hardware, does it make sense using isolation and container technologies? Commented Feb 13, 2019 at 9:00
  • @RuiFRibeiro I think the benefit is huge, especially due to the many installations and configurations you have to do, but there is not much documentation and connecting to external devices can be a real pain. In my case, to emulate an AVD, I just expose /dev/kvm and the port 5900 and I'm able to connect with a remote desktop client like Remmina through VNC easily (I just install the vnc client on the host), everything else in the image. I don't even need to run the container with the privileged flag (that I avoid at all costs). Now I'm trying to find how to see the device in chrome. Commented Jul 11, 2019 at 19:18

1 Answer 1

0

I achieved that by:

1) Exposing the ports: 5037, 5554, 5555 and 5900 (instead of just 5037).

2) Running socat inside the container on the exposed ports, passing the container ip (you can put it in an entrypoint file, or run before other commands):

(assuming the ip is 172.23.0.2)

socat tcp-listen:5037,bind=172.23.0.2,fork tcp:127.0.0.1:5037 &
socat tcp-listen:5554,bind=172.23.0.2,fork tcp:127.0.0.1:5554 &
socat tcp-listen:5555,bind=172.23.0.2,fork tcp:127.0.0.1:5555 &

If you define a hostname for the container (docker run --hostname...), you can use the hostname instead of the ip (which is better, because the ip can change) in the socat command. For example, if the hostname is android-emulator you can run the above commands as:

socat tcp-listen:5037,bind=android-emulator,fork tcp:127.0.0.1:5037 &
socat tcp-listen:5554,bind=android-emulator,fork tcp:127.0.0.1:5554 &
socat tcp-listen:5555,bind=android-emulator,fork tcp:127.0.0.1:5555 &

3) Adding the ip of the docker container to chrome inspect, in Configure... (e.g.: 172.23.0.2:5037, using the ip here, because it must be seen outside the container).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .