Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

adb-docker

A small Docker image that runs an Android Debug Bridge (adb) server, giving you access to platform tools such as adb and fastboot from inside a container.

This repository is a fork of tiiuae/adb-docker, which itself derives from sorccu/adb. It is based on Alpine to keep the image small and adds an entrypoint that starts the ADB server and sets up reverse port forwarding (tcp:9696 and tcp:4223) automatically once a device connects.

Image

ghcr.io/mrmeganova/adb-docker:latest

Pull it with:

docker pull ghcr.io/mrmeganova/adb-docker:latest

Requirements

The container needs access to the host's USB bus to talk to a physical device:

  • It must run with --privileged.
  • The host's /dev/bus/usb must be mounted into the container.

Quick start

Start the ADB server and expose it on the host:

docker run -d --privileged \
  -v /dev/bus/usb:/dev/bus/usb \
  -p 5037:5037 \
  --name adbd \
  ghcr.io/mrmeganova/adb-docker:latest

Plug in your device, then list it:

docker exec adbd adb devices

You should see something like:

List of devices attached
0123456789ABCDEF	device

Examples

Run a one-off adb command

docker run --rm --privileged \
  -v /dev/bus/usb:/dev/bus/usb \
  ghcr.io/mrmeganova/adb-docker:latest \
  adb devices

Open a shell on the device

docker exec -it adbd adb shell

Install an APK

docker run --rm --privileged \
  -v /dev/bus/usb:/dev/bus/usb \
  -v "$PWD:/apks" \
  ghcr.io/mrmeganova/adb-docker:latest \
  adb install /apks/app.apk

Connect from a remote machine

With the server running and 5037 published (see Quick start), point a remote adb client at the host:

adb -H <server-ip> -P 5037 devices

Security

The image ships with a built-in RSA key so you don't have to authorize a new key on the device every time the container starts. This is convenient, but it means anyone holding that key can reach your device over ADB. To use your own key instead, mount your key folder over /root/.android:

docker run -d --privileged \
  -v /dev/bus/usb:/dev/bus/usb \
  -v /your/key_folder:/root/.android \
  -p 5037:5037 \
  --name adbd \
  ghcr.io/mrmeganova/adb-docker:latest

Scripts

The scripts/ folder contains debloat and configuration scripts for Android devices (TV and smartphone), meant to be run through this container. See scripts/README.md for details.

Systemd units

Sample systemd units are provided in the systemd/ folder to run the daemon as a managed service. Copy them to /etc/systemd/system/, then:

systemctl enable --now adbd

Run systemctl daemon-reload after editing any unit.

License

See LICENSE.

About

Dockerfile and instructions for ADB.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages