Answers: <p>As per <a href="https://github.com/docker/for-mac/issues/3110#issuecomment-456853036" rel="nofollow noreferrer">@pgayvallet comment on GitHub</a>:</p>
  
  <blockquote>
    <p>As the daemon runs inside a VM in Docker Desktop, <strong>it is not possible to actually share a mac host device with the container inside the VM</strong>, and this will most definitely never be possible.</p>
  </blockquote>
  
Answers: CC BY-SA 4.0
Answers: 2021-04-29T22:21:11.883Z
Answers: See also: https://fight-flash-fraud.readthedocs.io/en/stable/introduction.html#drive-permissions-passthrough
Answers: Alexey Vazhnov
Answers: CC BY-SA 4.0
Answers: 2019-01-23T16:03:26.087Z
Answers: 2019-01-23T16:03:26.087Z
Answers: kenorb
Answers: <p>Docker was built for linux, it runs on Mac through HyperkIT, which is a lightweight hypervisor. This means Docker only sees devices connected to the hyperkit hypervisor, rather than the devices connected to the Mac.</p>
  
  <p>Unfortunately, Hyperkit has issues with USB device passthrough from your MacOS to the hypervisor (read more <a href="https://github.com/moby/hyperkit/issues/149" rel="noreferrer">here</a>) so the --device command won't be much use to you here. You have three options,</p>
  
  <p>Option 1: Mount the ext4 drive to your Mac (not recommended)</p>
  
  <p>Whilst your Mac doesn't natively support ext4, there are ways around this. I have installed ext4fuse on your Mac by following <a href="https://apple.stackexchange.com/questions/210198/mount-ext4-on-el-capitan">this</a> tutorial. When you have mounted your device, add it to your ubuntu container with the -v flag,</p>
  
  <pre><code>docker run -v &lt;Your_volume&gt;:&lt;dest_volume&gt; -it ubuntu bash
  </code></pre>
  
  <p>Making sure that the directory of your volume has been added to the file sharing folders in Docker.</p>
  
  <p>Option 2: create a docker-machine using the virtualbox driver and add the device to the virtualbox vm (still not recommended)</p>
  
  <p>Follow this great tutorial <a href="https://milad.ai/docker/2018/05/06/access-usb-devices-in-container-in-mac.html" rel="noreferrer">here</a> which goes through installing a docker machine with a virtualbox driver and mounting the USB stick.</p>
  
  <p>Option 3: Run Docker on linux (recommended!)</p>
  
  <p>I wouldn't recommend using Docker for Mac. It was built for linux and if you don't switch to linux you'll waste your time troubleshooting issues like these for no real reason.</p>
  
  <p>I've got a mac, but run a few ubuntu cores in virtualbox and then install docker on top of them, that way I can play around with docker starm too (which you can't with docker Mac unless you use docker-machine!</p>
  
Answers: CC BY-SA 4.0
Answers: 2020-03-09T14:54:19.580Z
Answers: Why is option 2 not recommended? what is the difference, in terms of safety, between that solution and using virtualbox directly?
Answers: GeekInDisguise
Answers: CC BY-SA 4.0
Answers: 2022-02-10T03:09:36.753Z
Answers: Good answer excepting the suggestion to switch to Linux.
Answers: greatvovan
Answers: CC BY-SA 4.0
Answers: 2018-12-27T14:54:13.853Z
Answers: 2018-12-27T14:54:13.853Z
Answers: rusty009
Body: <p>I've connected external HDD via USD on macOS, and I'm running Ubuntu's Docker container as:</p>
  
  <pre><code>docker run -it --device=/dev/disk3 --privileged ubuntu bash
  </code></pre>
  
  <p>but the device is not present in the container:</p>
  
  <pre><code># 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
  </code></pre>
  
  <p>Here is another attempt:</p>
  
  <pre><code>$ 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
  </code></pre>
  
  <p>Here is the device which I'm trying to add to the container (as reported on macOS):</p>
  
  <pre><code>$ 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      
  </code></pre>
  
  <p>Similar issues are posted here:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/q/35854886/55075">How do I access a USB drive on an OSX host from inside a Docker container?</a></li>
  <li><a href="https://stackoverflow.com/q/38736319/55075">How to mount a device of host to host in a Docker container?</a></li>
  </ul>
  
  <p>However, I cannot mount it on macOS host, as the partition is formatted to Linux file system (ext4) which is not supported. That's why I'm trying to pass through the device to the Linux Docker container, but the device isn't shown.</p>
  
  <p>What am I missing?</p>
  
Tags: <docker><linux><macos>
Title: How to pass a /dev/disk device on macOS into Linux Docker?
UserDisplayName: kenorb
ThreadText: # How to pass a /dev/disk device on macOS into Linux Docker?
  
  (Asked by: username_0 on 2018-07-22)
  
  I've connected external HDD via USD on macOS, and I'm running Ubuntu's Docker container as:
  
  ```
  docker run -it --device=/dev/disk3 --privileged ubuntu bash
  
  ```
  
  but the device is not present in the container:
  
  ```
  # 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
  
  ```
  
  Here is 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
  
  ```
  
  Here is the device which I'm trying to add to the container (as reported on macOS):
  
  ```
  $ 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      
  
  ```
  
  Similar issues are posted here:
  
  * [How do I access a USB drive on an OSX host from inside a Docker container?](https://stackoverflow.com/q/35854886/55075)
  * [How to mount a device of host to host in a Docker container?](https://stackoverflow.com/q/38736319/55075)
  
  However, I cannot mount it on macOS host, as the partition is formatted to Linux file system (ext4) which is not supported. That's why I'm trying to pass through the device to the Linux Docker container, but the device isn't shown.
  
  What am I missing?
  
  **Tags:** docker, linux, macos
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2018-12-27. Score: 5 | Accepted answer
  
  Docker was built for linux, it runs on Mac through HyperkIT, which is a lightweight hypervisor. This means Docker only sees devices connected to the hyperkit hypervisor, rather than the devices connected to the Mac.
  
  Unfortunately, Hyperkit has issues with USB device passthrough from your MacOS to the hypervisor (read more [here](https://github.com/moby/hyperkit/issues/149)) so the --device command won't be much use to you here. You have three options,
  
  Option 1: Mount the ext4 drive to your Mac (not recommended)
  
  Whilst your Mac doesn't natively support ext4, there are ways around this. I have installed ext4fuse on your Mac by following [this](https://apple.stackexchange.com/questions/210198/mount-ext4-on-el-capitan) tutorial. When you have mounted your device, add it to your ubuntu container with the -v flag,
  
  ```
  docker run -v <Your_volume>:<dest_volume> -it ubuntu bash
  
  ```
  
  Making sure that the directory of your volume has been added to the file sharing folders in Docker.
  
  Option 2: create a docker-machine using the virtualbox driver and add the device to the virtualbox vm (still not recommended)
  
  Follow this great tutorial [here](https://milad.ai/docker/2018/05/06/access-usb-devices-in-container-in-mac.html) which goes through installing a docker machine with a virtualbox driver and mounting the USB stick.
  
  Option 3: Run Docker on linux (recommended!)
  
  I wouldn't recommend using Docker for Mac. It was built for linux and if you don't switch to linux you'll waste your time troubleshooting issues like these for no real reason.
  
  I've got a mac, but run a few ubuntu cores in virtualbox and then install docker on top of them, that way I can play around with docker starm too (which you can't with docker Mac unless you use docker-machine!
  
  > **Comments:**
  > **username_3**: Why is option 2 not recommended? what is the difference, in terms of safety, between that solution and using virtualbox directly?  
  > **username_4**: Good answer excepting the suggestion to switch to Linux.  
  
  ---
  
  ### Answer by username_0 on 2019-01-23. Score: 2
  
  As per [@pgayvallet comment on GitHub](https://github.com/docker/for-mac/issues/3110#issuecomment-456853036):
  
  > 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.
  
  > **Comments:**
  > **username_1**: See also: https://fight-flash-fraud.readthedocs.io/en/stable/introduction.html#drive-permissions-passthrough  
  
  ---
  
  