docker/for-mac

Cannot pass --device=/dev/disk3 on macOS into Linux Docker?

kenorb opened this issue ยท 9 comments

  • I have tried with the latest version of my channel (Stable or Edge)
  • I have uploaded Diagnostics
  • Diagnostics ID: D1F5CC9C-9C89-4621-8781-F9AC7308134F

Expected behavior

I'd like to pass /dev/disk3 device into Docker, so I'm running the following command:

docker run -it --device=/dev/disk3 --privileged ubuntu bash

or:

docker run -it --device=/dev/disk3:/dev/sdb --privileged ubuntu bash

then I expect to have access to this device inside the container, so it can be mounted (as ext4 in this case).

Actual behavior

$ docker run -it --device=/dev/disk3 --privileged ubuntu bash
# ls /dev/disk3
ls: cannot access '/dev/disk3': No such file or directory
# fdisk -l
Disk /dev/sda: 59.6 GiB, 63999836160 bytes, 124999680 sectors
Device     Boot Start       End   Sectors  Size Id Type
/dev/sda1  *     2048 124999679 124997632 59.6G 83 Linux

Another attempt:

$ docker run -it --device=/dev/disk3:/dev/sdb --privileged ubuntu bash
# ls /dev/sdb*
ls: cannot access '/dev/sdb*': No such file or directory
# fdisk -l
Disk /dev/sda: 59.6 GiB, 63999836160 bytes, 124999680 sectors
Device     Boot Start       End   Sectors  Size Id Type
/dev/sda1  *     2048 124999679 124997632 59.6G 83 Linux

The device is present on the macOS host:

$ diskutil list /dev/disk3
/dev/disk3 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *1.0 TB     disk3
   1:                      Linux                         1.0 TB     disk3s1

$ sudo fdisk /dev/disk3
Disk: /dev/disk3    geometry: 121601/255/63 [1953525167 sectors]
Signature: 0xAA55
         Starting       Ending
 #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
------------------------------------------------------------------------
 1: 83 1023 254  63 - 1023 254  63 [         2 - 1953525165] Linux files*
 2: 00    0   0   0 -    0   0   0 [         0 -          0] unused      
 3: 00    0   0   0 -    0   0   0 [         0 -          0] unused      
 4: 00    0   0   0 -    0   0   0 [         0 -          0] unused   

but it's not present in the container after passing through --device parameter.

Information

  • macOS Version: 10.13.5
  • Engine: 18.03.1-ce
  • Compose: 1.21.1
  • Machine: 0.14.0

It's reproducible each time.

Diagnostic logs

No errors reported in the logs

Steps to reproduce the behavior

  1. Connect external USD HDD formatted with FS not readable by macOS, so it cannot be mounted, such as ext4.
  2. Run docker run -it --device=/dev/disk3 --privileged ubuntu bash (where /dev/disk3 is your device number on the host).

Related

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale comment.
Stale issues will be closed after an additional 30d of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle stale

+1 :)

Docker:

Client:
Version: 18.06.1-ce
API version: 1.38
Go version: go1.10.3
Git commit: e68fc7a
Built: Tue Aug 21 17:21:31 2018
OS/Arch: darwin/amd64
Experimental: false

Server:
Engine:
Version: 18.06.1-ce
API version: 1.38 (minimum version 1.12)
Go version: go1.10.3
Git commit: e68fc7a
Built: Tue Aug 21 17:29:02 2018
OS/Arch: linux/amd64
Experimental: true

macOS 10.14 Mojave

tsal commented

Not sure if I can do this, but since this is still an issue (experiencing it myself with stable and edge):

/remove-lifecycle stale

Hello,

Sorry for the late answer.

As the daemon runs inside a VM in Docker Desktop, it is not possible to actually share a mac host device with the container inside the VM, and this will most definitely never be possible.

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale comment.
Stale issues will be closed after an additional 30d of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle stale

Wontfix. Wow. Ok. But what about a small alert when using this?
People spending hours with this problems.

Well... I've spent a little time on this and came to this thread. Soon after I found it was on documentation. +1 On advising user that it cannot be done on mac/windows
https://docs.docker.com/docker-for-mac/faqs/#can-i-pass-through-a-usb-device-to-a-container

masto commented

FWIW, I also lost about an hour of my life to finding this.

Closed issues are locked after 30 days of inactivity.
This helps our team focus on active issues.

If you have found a problem that seems similar to this, please open a new issue.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle locked