Skip to content

Recursive bind mounting #3782

@pwaller

Description

@pwaller

I just had a nasty surprise today with some disappearing files.

On my host system I have /opt/foo/bar, which is a mount point for /dev/mapper/foo-bar. I'm running a container with -v/opt/foo:/foo, which writes to /foo/bar/baz. It's writing underneath the mount point, so I can't see the changes written to /foo/bar/baz on the host unless I umount /opt/foo/bar.

According to the mount man page, this is the expected behaviour of ordinary bind mounts, but another type of mount is a --rbind one. Both myself and a colleague think that the principle of least surprise would be to make the whole host filesystem at the bind mount location appear inside the container, not just the "top one". Others may disagree, but I thought I'd open up discussion here.

Workaround: Execute docker run -v=/opt/foo:/foo -v/opt/foo/bar:/foo/bar <image> <run>.

/cc @drj11

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions