-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Description
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