2

I'm trying to start a JAVA server (SPRING) container which runs ADB commands. I have created a docker-compose (I start many containers together..) file but I can't see the devices connected on the machine. I found solutions on how to do this as mention here but it doesn't uses docker compose.

Note: I use Docker for windows 10.

This is what I wrote down in the meantime:

version: '3.8'
services:
  java-server:
  image: openjdk:8
  privileged: true       <----- I thought this should help
  pid: "host"
  ports:
    - target: 80
      published: 80
      protocol: tcp
      mode: host
    - target: 5037           <----- I thought this should help, expose the adb port
      published: 5037
      protocol: tcp
      mode: host
  networks:
  - default

volumes:
 - "/C/Users/user/StudioProjects/pc-java-app/apache2-entrypoint.sh:/var/lib/mysql/data/apache2-entrypoint.sh"
 - "/C/Users/user/StudioProjects/pc-java-app/target/java-server-0.1.25.6.jar:/var/lib/mysql/data/java-server-0.1.25.6.jar"

command: >
    bash -c "apt-get update && apt-get install -y android-tools-adb && /bin/bash && cd /var/lib/mysql/data/ && ls -l && adb devices && java -jar java-server-0.1.25.6.jar"

networks:
  mt-network:
  driver: bridge

volumes:
  my-db:

and getting:

# adb devices
 List of devices attached

#

Thank you!

Itai.S.
  • 144
  • 13

1 Answers1

0

I do not know if you have already solved this problem, I tested this your docker-compose and managed to run without problems adding to the volumes

- /dev/bus/usb:/dev/bus/usb

So the container will have access to the folder of your local machine.

No need to add the adb port to the file.

I hope it helped someone.

Edson Vitor
  • 336
  • 4
  • 4
  • this works on linux, on windows it has no meaning – Itai.S. Mar 10 '21 at 10:08
  • I found an [article](https://blog.codemagic.io/how-to-dockerize-flutter-apps/#for-macos-and-windows-users) that might help you with that https://blog.codemagic.io/how-to-dockerize-flutter-apps/#for-macos-and-windows-users – Edson Vitor Mar 16 '21 at 23:39