'Access to raw disk device in Docker container on Mac

Is there a way to access to raw disk device in Docker container on Mac?

I would like to mount ext4 filesystem in docker container and edit contents with linux(not mac) tools. I tried ex4fuse but it stalls on write operation, reads always fine.



Solution 1:[1]

For ubuntu 18LTS running on a lenovo SE350, the following command worked like a charm for me:

docker run --rm -it --privileged --device=/dev/sda:/dev/sda  gdisk:latest bash

I believe this did the magic

--privileged --device=/dev/sda:/dev/sda 

Solution 2:[2]

In short, it doesn't seem that there is a straightforward and elegant way of using Docker to access an ext4 volume on a macOS host without using FUSE or full virtualisation.

This topic has been covered in further detail on the DevOps StackExchange

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 pPanda_beta
Solution 2 Mark