Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access to raw disk device in Docker container on Mac

Tags:

docker

disk

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.

like image 717
kyb Avatar asked Oct 12 '25 03:10

kyb


2 Answers

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 
like image 159
pPanda_beta Avatar answered Oct 14 '25 17:10

pPanda_beta


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

like image 22
Mark Avatar answered Oct 14 '25 19:10

Mark