Search code examples
androiddockeradb

Connecting to a USB Android device in a Docker container via ADB


I have created a Docker image which contains the Android SDK and am trying to expose my Android phone in a container running this image. So I used the --privileged flag and mounted the USB devices as follows:

$ docker run --privileged -v /dev/bus/usb:/dev/bus/usb -d -P my-android:0.0.1

However, when I run ADB devices, it does not show me the USB device:

ubuntu@d56b666be455:~/Android/Sdk/platform-tools$ ./adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached

ubuntu@d56b666be455:~/Android/Sdk/platform-tools$

lsusb inside the container lists the device:

ubuntu@d56b666be455:~$ lsusb
...
Bus 002 Device 017: ID 04e8:6866 Samsung Electronics Co., Ltd GT-I9300 Phone [Galaxy S III] (debugging mode)

The device is however visible on the host:

⇒  ./adb devices
List of devices attached
4d11abcd65b74045    device

Host OS

$ uname -a
Linux ananya 3.16.0-33-generic #44~14.04.1-Ubuntu SMP Fri Mar 13 10:33:29 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Docker version

$ docker --version
Docker version 1.5.0, build a8a31ef

What could be the issue?


Solution

  • I don't think the ADB daemon running on the device can be connected to two ADB servers. Try disconnecting it from your host machine's ADB and then connect it to the Docker container's ADB.