Using loop devices in docker without --privileged flag

3.3k views Asked by At

Is there any way to use loop devices within docker container without switching on a privileged mode. It looks like there should be a way with adding capabilities, but even when I run container with flag --cap-add=ALL I still get an error when I execute losetup -f command:

[root@176f9063d3bb /]# losetup -f losetup: Could not find any loop device. Maybe this kernel does not know about the loop device? (If so, recompile or 'modprobe loop'.)

1

There are 1 answers

0
miki hayut On

you can use add cap and enabled the specific device to use this :

docker run -td --cap-add SYS_ADMIN  --device /dev/loop0 --device /dev/loop-control