It hasn't always behaved this way, but nowadays I get this inconsistent behaviour. Bind mounts don't copy existing mounts (unless you use
--rbind), but new mounts (and unmounts) get copied automatically. It seems like a bug. What causes this?
# mount --bind / /mnt/tmp # mount | grep /mnt /dev/mapper/fedora-root on /mnt/tmp type ext4 (rw,relatime,seclabel,data=ordered) # mount /var/lib/docker # mount | grep mnt /dev/mapper/fedora-root on /mnt/tmp type ext4 (rw,relatime,seclabel,data=ordered) /dev/mapper/fedora-docker on /mnt/tmp/var/lib/docker type ext4 (rw,relatime,seclabel,data=ordered)
This happens on Fedora Workstation 23. I believe Debian 8 is also affected.
It doesn't happen if I boot bash with no other processes, i.e.
init=/bin/bash. So it doesn't seem to be inherent to the Linux kernel.
It's annoying because this used to be the simplest way to move files from the root filesystem into a new mount point. It would be particularly convenient with SELinux (at least if you use
cp?), because the files would be labeled automatically, avoiding the need for
restorecon or the like.