Beginner Question on running a Django app and ADB

Hi. I’m new to Docker and have got a Django app up and running without too much issue. The bit im now stuck on and cant find many answers on is how I would include android Debug Bridge (ADB) with it.

So, just for context. I have a Django app that runs on a Raspberry Pi in kiosk mode and it then connects via ADB to several Android Tablets which it can then run certain adb commands via the django app.

Where im stuck is, when I run the docker-compose file I presume i’d need to install ADB and then get it to run so that the Django app can then utilise the adb commands. Thats where I get stuck, how would i install that with docker and then get it to run?

Heres what I have currently::


version: '3'

    build: .
    command: bash -c "python makemigrations && python migrate && python runserver"
    container_name: affinity-manager
      - .:/affinity-manager
      - "8000:8000"


# The first instruction is what image we want to base our container on
# We Use an official Python runtime as a parent image
FROM python:3.9

# The enviroment variable ensures that the python output is set straight
# to the terminal with out buffering it first

# create root directory for our project in the container
RUN mkdir /affinity-manager

# Set the working directory to /music_service
WORKDIR /affinity-manager

# Copy the current directory contents into the container at /music_service
ADD . /affinity-manager/

# Install any needed packages specified in requirements.txt
RUN pip install -r requirements.txt

RUN apt-get -y update
RUN apt-get install -y android-tools-adb
# Expose default ADB port

# Set up PATH
ENV PATH $PATH:/opt/platform-tools

# Start the server by default
CMD ["adb", "start-server"]

Note that I used adb only years ago and never in a container, but if adb listens on a TCP port, you can just run it in a different container and share the network namespace.

      # ...
      network_mode: "service:adb"
      # ...

That way both containers would use the exact same network so localhost would be the ame localhost fo both of them if it helps to access adb.

Otherwise you could use a process managrer like s3-init or supervisor to run multiple pocesses in one container.