Skip to content

Connect Each Device to a separate container - ADB fails when a second device attached #172

@idekterev

Description

@idekterev

The Readme states you can use something like the following to connect each device to a separate container:

$ docker run -d -p 4723:4723 --device /dev/bus/usb/XXX/YYY:/dev/bus/usb/XXX/YYY -v ~/.android:/root/.android --name device1 appium/appium

For some reason, when running a container using the described method to '--device /dev/bus/usb/XXX/YYY:/dev/bus/usb/XXX/YYY', the moment a second device is plugged in, ADB stops inside the first container. This basically means that multiple appium containers cannot run as adb fails the moment there is more than one.

Host: Ubuntu 22.04
Docker version 27.5.1, build 9f9e405

Steps:

  1. One device connected via USB, lsusb lists it as /dev/bus/usb/002/042.

  2. Docker run command:
    adb kill-server && docker run --rm -p 4723:4723 --device=/dev/bus/usb/002/042 appium/appium:local

  3. Check adb devices in container 1: running "docker exec -it CONTAINERID adb devices" correctly lists one device connected.

  4. Plug in second ADB device via USB

  5. repeat step 3 (check adb devices in container): adb to fail inside the first container:

* daemon not running; starting now at tcp:5037
ADB server didn't ACK
Full server startup log: /tmp/adb.1300.log
Server had pid: 57
--- adb starting (pid 57) ---
02-19 10:00:10.534    57    57 I adb     : main.cpp:63 Android Debug Bridge version 1.0.41
02-19 10:00:10.534    57    57 I adb     : main.cpp:63 Version 35.0.2-12147458
02-19 10:00:10.534    57    57 I adb     : main.cpp:63 Installed as /opt/android/platform-tools/adb
02-19 10:00:10.534    57    57 I adb     : main.cpp:63 Running on Linux 6.11.0-17-generic (x86_64)
02-19 10:00:10.534    57    57 I adb     : main.cpp:63
02-19 10:00:10.535    57    57 I adb     : auth.cpp:416 adb_auth_init...
02-19 10:00:10.535    57    57 I adb     : auth.cpp:220 User key '/home/androidusr/.android/adbkey' does not exist...
02-19 10:00:10.535    57    57 I adb     : auth.cpp:64 generate_key(/home/androidusr/.android/adbkey)...
02-19 10:00:10.735    57    57 I adb     : auth.cpp:152 loaded new key from '/home/androidusr/.android/adbkey' with fingerprint 80F96A80CCB1DD12A7534A67492D8E938101295E6896B8D9E28BF2411F156798
02-19 10:00:10.735    57    57 I adb     : auth.cpp:391 adb_auth_inotify_init...
02-19 10:00:10.735    57    57 I adb     : udp_socket.cpp:170 AdbUdpSocket fd=15
02-19 10:00:10.735    57    57 I adb     : udp_socket.cpp:274 SetMulticastOutboundInterface for index=44
02-19 10:00:10.735    57    57 I adb     : udp_socket.cpp:533 bind endpoint=0.0.0.0:5353
02-19 10:00:11.546    57    57 E adb     : usb_libusb.cpp:598 failed to open device: No such device (it may have been disconnected)
02-19 10:00:11.546    57    57 I adb     : transport.cpp:1153 00002401181035280063: connection terminated: failed to open device: No such device (it may have been disconnected)

* failed to start daemon
adb: failed to check server version: cannot connect to daemon

Is this a bug, or does anyone have any ideas as to why this is happening?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions