Closed argeas closed 7 years ago
Found a solution : lsusb to show devices. then I run container using the following to allocate specific device per container :
docker run -d -t -i --device=/dev/bus/usb/001/003 --name s3 appium/test1:latest
Were the first number, the Bus, is 001. The second number, the Device, is 003.
bash-4.4# lsusb Bus 001 Device 003: ID 04e8:6860
Great.
How to get Bus and Device number. Do you refer device ID as device number?
when you run lsusb in the terminal window you get a list of connected devices in the format: Bus 020 Device 013: ID 1004:61f9 LG Electronics Inc. LGE Android Phone Serial: 02e85ac75cc8cf82
Where in this case ID is the USB Hardware vendor id, BUS is the usb bus asssigned to the device and Device is the USB port assigned to the device. Note: in the case of 2 nexus5 (or LG, Sony etc.. ) devices the ID will be the same since they have the same hardware
The only way to match the desired device with the desired usb bus and device is greping the the serial of the device and extracting the respective usb bus and Device (port) from the printed line of the terminal.
This can be done with a simple bash script line. e.g
lsusb | grep 02e85ac75cc8cf82 | awk '{print $2"/"$4}' | sed 's/:$//'
you will have to edit it a bit to make it work for you
One other approach to do is by setting up a small device farm using OpenSTF. OpenSTF provides API to connect remote device. So, inside the docker before running the appium server you can call OpenSTF API to reserve the device and then run automation on it.
Here is a simple example to show how to use OpenSTF API https://github.com/openstf/stf-appium-example
Thanks @argeas @vbanthia Let me try both approaches.
@argeas @vbanthia I have tried the below steps and got error as : docker: Error response from daemon: driver failed programming external connectivity on endpoint container-appium-one (29bcfef1a27c5cf23e2c028ae3727c26b366bb9f6e32c73a1cd5fd3aa30106b6): Bind for 0.0.0.0:4723 failed: port is already allocated. Steps followed:
there is na issue regarding running more than 1 device. E.g. I have 2 devices and start one container. then I start another container. running adb devices on the first container shows the devices. running adb devices on the second doesnt show anything. If I unplug and replug one device it is then seen by the second container. ( 1 on each container when running adb devices )