"--privileged" works for me.
loopback device in a Linux container? - Server Fault
http://serverfault.com/questions/701384/loopback-device-in-a-linux-container
The quick answerlinux - Is it possible to mount an ISO inside a docker container? - Stack Overflow
An alternativedocker run --privileged=true ...
sudo losetup /dev/loop0 test.img mount /dev/loop0 /mnt docker run -v /mnt:/mnt ...
http://stackoverflow.com/questions/22028795/is-it-possible-to-mount-an-iso-inside-a-docker-container
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.