DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Cover image for How to Connect an Android Phone to a Docker Container ? - ADB, Docker, VSCode
RΓ©mi Lavedrine
RΓ©mi Lavedrine

Posted on • Updated on

How to Connect an Android Phone to a Docker Container ? - ADB, Docker, VSCode

So, You decided to develop in Docker containers. 🐳

That’s a good choice because it solves a lot of problems. πŸ‘ŒπŸΌ
On the other hand, it adds new ones. πŸ˜…

Great, We, developers, love to solve problems. πŸ‘πŸΌπŸ§‘πŸΌβ€πŸ’»


In the video below, I show you how to connect your Android phone, via ADB, to your Linux machine.

No worries, it’s easy as pie.

Follow the steps described in the video below, and you should be able to interact with your android phone from your Docker Container on a Linux Host.

Video with French Audio & English Subtitles


If you are more a reading person, just follow the steps below.

First you have to have VSCode installed as we are going to develop in a Docker Container using VSCode and the Remote Container extension.

Everything you’re doing here is done on a Linux host machine. The steps are different on MacOS or Windows.

I did all of it on an Ubuntu machine, so tell me if you tested it on another distro and it worked (or not).

You have to describe the Dockerfile you are going to use to develop in a Docker Container.

Here is the one I used in the video :

# Pull Ubuntu LTS image.
FROM shostarson/base-dev-env:v1

# Labels and Credits
LABEL \
name=”Adb on Linux Host” \
author=”RΓ©mi Lavedrine <remi@github.com>” \
maintainer=”RΓ©mi Lavedrine <remi@github.com>” \
description=”Adb in Docker Container on a Linux Host machine.”

ENV SRC_DIR=/root/home/adb-linux

WORKDIR $SRC_DIR

COPY . .

RUN apt update -y && apt install -y β€” no-install-recommends android-tools-adb
Enter fullscreen mode Exit fullscreen mode

And the .devcontainer.json file that describes the configuration for this container on VSCode.

You just have to add these args to the file :

β€œrunArgs”: [ β€œ β€” privileged”,
β€œ-v”,
β€œ/dev/bus/usb:/dev/bus/usb” ],
Enter fullscreen mode Exit fullscreen mode

Rebuild everything in the Container and you are good to go.

Try adb devices on your Container with your Android phone connected to your host machine. You should see your device as an authorized one.

Tip :

Don’t forget that an Android phone can be connected to only one ADB server at a given time. So if it’s not working get sure that an ADB server is not running on your host machine.

If so, kill it and retry in your Docker Container.


I hope you enjoyed it and that it helps you to use Docker and Containers at their maximum possibilities.

If you like this content, push the like button, that helps spread the message. πŸ‘πŸΌ
If you think it can be useful to anyone in your network, share it. πŸ“¨


Video produced by Wild & Secure, your consulting firm to all things security and real estate.
If you want to receive weekly quality content about security, subscribe to our newsletter on our website.

Top comments (0)

All DEV content is created by the community!

Hey, if you're landing here for the first time, you should know that this website is a global community of folks who blog about their experiences to help folks like you out.

Sign up now if you're curious. It's free!