Skip to main content
3 of 4
edited body
sourcejedi
  • 53.5k
  • 23
  • 178
  • 336

mount namespaces differ in the arrangement of mounted filesystems.

This is very flexible, because mounts can be bind mounts of a sub-directory within a filesystem.

# unshare --mount
# mount --bind /usr/bin/ /mnt/
# ls /mnt/cp
/mnt/cp
# exit

# ls /mnt/cp
ls: cannot access '/mnt/cp': No such file or directory

You can list your current set of mounts with the findmnt command.

In a full container, the root mount is replaced and you work with an entirely separate tree of mounts. This involves some extra details, such as the pivot_root() system call. You probably don't need to know exactly how to do that. Some details are available here: How to perform chroot with Linux namespaces?

sourcejedi
  • 53.5k
  • 23
  • 178
  • 336