2015年8月12日 星期三

Use loopback device in docker


"--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 answer
docker run --privileged=true ...
An alternative
sudo losetup /dev/loop0 test.img
mount /dev/loop0 /mnt
docker run -v /mnt:/mnt ...
linux - Is it possible to mount an ISO inside a docker container? - Stack Overflow
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:
  • access to loop devices,
  • permission to mount filesystems.
By default, Docker locks down both things; that's why you get that error message.
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.


沒有留言: