title: How to use loop devices locally in Docker
body: <p>I want to use loop devices in a docker container locally. It means, when running a couple of container all of them should have for instance a /dev/loop0 connected to a file local in the container. I tried</p>
  
  <pre><code>[root@600bbfb452d1 /]# mknod /dev/loop20 b 7 20
  [root@600bbfb452d1 /]# dd if=/dev/random of=loopfile1 bs=1M count=2
  [root@600bbfb452d1 /]# losetup -a | grep 20
  /dev/loop20: [0049]:3553002 (/loopfile1)
  </code></pre>
  
  <p>so far so good. But going back to host I can see:</p>
  
  <pre><code>[loewe@linux-2 ~]$ losetup -a | grep 20
  /dev/loop20: []: (/loopfile1)
  </code></pre>
  
  <p>the loop device /dev/loop20 was also created in the hosts /dev - as my fear was because of the tmpfs mount - and worst the container local file "loopfile1" is attached to hosts loop dev.</p>
  
  <p>I tries to umount the /dev filesystem in the container but didn't succeed (device busy but no proc visible with lsof).</p>
  
  <p>Any idea what I am doing wrong?</p>
  
  <p>BTW: using iscsi devices in a container should have the same problem.</p>
  
  <p>Thanks Heiko</p>