3

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.

Software Engineer
  • 15,457
  • 7
  • 74
  • 102
kyb
  • 7,233
  • 5
  • 52
  • 105

2 Answers2

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 
pPanda_beta
  • 618
  • 7
  • 10
  • I think the questions is asking for a way to access a drive directly on a Docker image but with a macOS host system. I don't know if this will work on macOS but, as you're using a Lenovo, I don't think you can guarantee it will work on macOS – moo Jan 23 '22 at 19:08
  • Tried `--device=/dev/disk2s2:/dev/sdc` on Mac, it gives "docker: Error response from daemon: error gathering device information while adding custom device "/dev/disk2s2": not a device node". – greatvovan Feb 10 '22 at 02:29
1

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

moo
  • 1,597
  • 1
  • 14
  • 29