"--privileged" works for me.
loopback device in a Linux container? - Server Fault
The quick answerlinux - Is it possible to mount an ISO inside a docker container? - Stack Overflow
docker run --privileged=true ...
sudo losetup /dev/loop0 test.img mount /dev/loop0 /mnt docker run -v /mnt:/mnt ...
To mount an ISO inside a container, you need two things:
By default, Docker locks down both things; that's why you get that error message.
- access to loop devices,
- permission to mount filesystems.
The easiest solution is to start the container in privileged mode (
docker run -privileged ...).
A more fine-grained solution is to dive down into the devices cgroup and container capabilities to give the required permissions.
Note that you cannot execute privileged operations as part of a Dockerfile; i.e. if you need to mount that ISO in a Dockerfile, you won't be able to do it.