How to connect adb devices to linux container

Assuming that you have Ubuntu image pulled in docker , in case not!  you can download with command

docker pull ubuntu  


For more reference you can refer below link

 https://docs.docker.com/engine/reference/commandline/pull/#pull-an-image-by-digest-immutable-identifier  

Once the image is downloaded, you can check like below

 docker images | grep ubuntu  





To run the image as container

 docker run -ti -d --privileged ubuntu  


Check container id

 docker ps  




Lets run the command inside container , using container id

 docker exec -ti 8991d0a7f32c /bin/bash  




Verify if lsusb is installed or not , lsusb is used to know the hardware devices attached to the host machine.

lsusb



As per above error , lsusb is not recognized , so we need to install it.

 apt-get update   



 apt-get install usbutils  




Check lsusb now



Great !! lsusb is now installed on your container

next step is to check java and install it in case it is not there in container

java -version  


Again Java is not installed, need to install it on container


 apt-get install openjdk-8-jdk  



Adding java to path


 export PATH=$PATH:/usr/lib/jvm/java-8-openjdk/bin 




Check java installation


 As Java is up and running now, We now need to proceed for android sdk tools installation

first we need to install wget to get the android sdk tools setup

 apt install wget  



 wget http://dl.google.com/android/android-sdk_r24.2-linux.tgz  
 

 adb devices  

 apt-get install android-tools-adb  





Exit from container and commit the changes with your image_name

docker commit 8991d0a7f32c adb_demo





adb-kill server to kill any running instance in host machine , other wise adb devices will not be visisble in container



Start your image as container with mapping of Volume drive with -V options






Lets find the container id again
 


Executing some command on container



Verify if adb devices is detecting your android phone or not , i have connected an android device to my host machine





There we go!!

Your adb devices are now detected on container.

Comments

  1. This article is a creative one and the concept is good to enhance our knowledge. Waiting for more updates.
    Android Development Course Online
    Online Courses for Content Writing

    ReplyDelete
  2. Nice blog, very informative content.Thanks for sharing, waiting for the next update…

    c programming classes in coimbatore

    ReplyDelete
  3. I truly like perusing a post that can make individuals think. Likewise, much obliged for allowing me to remark!best interiors

    ReplyDelete

Post a Comment

Popular posts from this blog

How to start with APPIUM PYTHON

Configuring jenkins with Robot Framework