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
This doesn't answer the exact question you were asking, but does address what you were trying to accomplish - connecting to an android device connected to a docker host from an adb client running inside a docker container. I'm including this for anyone trying to accomplish the same thing (like I was).
The adb client supports a -H
option which tells it where to find the adb server to connect to. Docker supports the hostname "host.docker.internal" which always maps to the IP address of the docker host. Assuming your device is connected to the docker host, you can do the following to get your containerized adb client to connect to the adb server running on the docker host:
adb -H host.docker.internal devices
Accomplishes the goal without having to mount the USB ports.
Reference: https://developer.android.com/studio/command-line/adb
Update: I recently learned that host.docker.internal is only supported on Docker for Mac in versions 18.0 and above.