通过 ADB 连接到 Docker 容器中的 USB Android 设备 [英] Connecting to a USB Android device in a Docker container via ADB

查看:96
本文介绍了通过 ADB 连接到 Docker 容器中的 USB Android 设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个包含 Android SDK 的 Docker 映像,并尝试在运行此映像的容器中公开我的 Android 手机.所以我使用了 --privileged 标志并安装了 USB 设备,如下所示:

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

但是,当我运行 ADB 设备时,它不显示 USB 设备:

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 列出了设备:

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

主机操作系统

$ 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 版本

$ docker --version
Docker version 1.5.0, build a8a31ef

可能是什么问题?

推荐答案

我不认为设备上运行的 ADB 守护进程可以连接到两个 ADB 服务器.尝试将其与主机的 ADB 断开连接,然后将其连接到 Docker 容器的 ADB.

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.

这篇关于通过 ADB 连接到 Docker 容器中的 USB Android 设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆