Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mobile devices under Mac Os X to connect to Docker

Tags:

docker

device

I'm trying to connect to my docker instance the devices I have connected to my laptop.

Concretely I have 4 devices (two iphones, two android) and I would like to be able to start 4 docker instances and connect each device to one instance.

What I expected to do is as simply as in ubuntu

docker run --privileged -v /dev/bus/usb:/dev/bus/usb -d -P my-android:0.0.1

But my host OS is a Mac OS X, also the instances I'm creating, because I need access to the instruments tool.

but so far I read that under mac os x, devices are connected directly though usb not being mounted.

this is what I got when I search for the iphone device:

      iPhone USB:
      Type: Ethernet
      BSD Device Name: en6
      IPv4:
          Configuration Method: DHCP
      IPv6:
          Configuration Method: Automatic
      Proxies:
          Exceptions List: *.local, 169.254/16
          FTP Passive Mode: Yes

Do you know how can I connect the devices to the docker instances?

Thanks!!!!

like image 824
RamonBoza Avatar asked Apr 21 '15 15:04

RamonBoza


People also ask

Does macOS support Docker?

Docker Desktop currently supports macOS Catalina, macOS Big Sur, and macOS Monterey. At least 4 GB of RAM. VirtualBox prior to version 4.3. 30 must not be installed as it is not compatible with Docker Desktop.

Can Docker run on M1 Mac?

Docker image was built in only seven minutes on MacBook M1 Pro, which was even better than the build time on my new VPS. This is not surprising, I gave Docker quite a lot of resources. But it also shows that if there are not too many I/O disk operations, performance is quite good.

Will Docker ever run natively on Mac?

Docker can't run natively since it uses linux kernel features not available on a mac.


1 Answers

I got this working with the docker-machine on virtualbox with the VirtualBox Extension Pack installed (provides support for USB 2.0 and USB 3.0 devices).

  • have the mobile phone connected to the host system.

    $ ioreg -p IOUSB | grep SAMSUNG
    +-o SAMSUNG_Android@14100000  <class AppleUSBDevice, id 0x100000c66, registered, matched, active, busy 0 (13 ms), retain 34>
    
  • create the a docker machine with the virtualbox driver (I've named it base)

    docker-machine create --driver virtualbox base
    
  • stop the machine to enable the USB Controller on the VM

    docker-machine stop base
    

Enable USB Controller

    docker-machine start base

- activate the base VM as docker host

    eval $(docker-machine env base)

- start ubuntu container with the usb devices mounted

    docker run -it --rm -v /dev/usb/bus:/dev/bus/usb ubuntu /bin/bash

- install the usbutils just to demo with lsusb that the android device is connected

    root@ce1e4be0bb73:/# apt-get update && apt-get install -y usbutils
  • 1st run of lsusb (did not show the device)

    root@ce1e4be0bb73:/# lsusb
    Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    
  • to show the device I had to unplug and plug again my phone, 2nd run of lsusb

    root@ce1e4be0bb73:/# lsusb
    Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
    Bus 001 Device 002: ID 04e8:6860 Samsung Electronics Co., Ltd Galaxy (MTP)
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    
like image 197
valentin_nasta Avatar answered Sep 28 '22 12:09

valentin_nasta