Unable to access Android USB Device from Docker Container

Unable to access Android USB Device from Docker Container

I want to run my appium tests on android device tethered through usb.

Docker Image: https://hub.docker.com/r/rgonalo/appium/

I created a virtualbox as mentioned in the docs-

docker-machine create --driver virtualbox default
docker-machine env default
eval "$(docker-machine env default)"
docker-machine start default

I grabbed the ip address and appium port and tried running tests, i keep getting no android devices found.

Note: I have installed the extension pack and added the device filter for the android device, I also did the “adb kill-server” on my host.

Anything that i am doing wrong?

Unfortunately, Docker for Mac does not support USB device pass-through at this time. Please see “Can I pass-through a USB device to a container?” at https://docs.docker.com/docker-for-mac/faqs/#/can-i-pass-through-a-usb-device-to-a-container. The recommended solution is to continue using Docker Toolbox if you require this feature. Sorry for the inconvenience.


On a Linux host machine, you just launch the Docker Container with the privileged argument and the /dev/bus/usb volume.
The command looks like this :
docker run -ti --privileged -v /dev/bus/usb:/dev/bus/usb -d 7ff25ab37633

On Mac OS, you can’t use the volume as it is not handle that way on Mac OS.

Following these steps, you should be able to connect to your Android Device, through adb within a Docker Container on a Mac host machine.

You can connect wirelessly to your device through adb.
So you just have to connect wirelessly and then connect to your device from your container. It works on Linux, Mac and Windows, so it is pretty consistent if you want to develop on a bunch of different OS.

The way to achieve it is :

  1. Connect your Android device to your host machine with a USB cable.
  2. On your host machine run :
    1. adb devices
  3. You should see your device as connected
  4. On your host machine run, to connect wirelessly to your device :
    1. adb tcpip 5555
    2. adb connect (replace the ip address with your android devices)
    3. adb devices
  5. You should see your device connected through USB and wirelessly
  6. Disconnect the USB cable, run adb devices and check that the wireless connection is still active
  7. Launch your Docker container
  8. On your Docker Container, run the following commands :
    1. adb connect
    2. adb devices

If you see and unauthorized device, try these commands to fix the issue :

  1. adb kill-server
  2. adb connect
  3. adb devices

I hope that will help some people.