Search code examples
dockermount

Cannot use mount within a Docker container


I'm trying to do the following within a Docker container:

docker run -it <image> bash
root$ dd if=/dev/zero of=file.fs bs=1024 count=1024
root$ mkfs.ext4 file.fs
root$ mkdir tmp
root$ mount -t ext4 file.fs tmp
**mount: tmp/: mount failed: Unknown error -1**
root$ dmesg
dmesg: read kernel buffer failed: Operation not permitted

The same commands above (with sudo) work fine on my host.

How can I get mount to succeed within the Docker container?


Solution

  • If permission error, you need add --privileged