Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error feedback when linux bind mount omits "bind" option? #1717

Open
mpuncel opened this issue Feb 11, 2018 · 1 comment
Open

Improve error feedback when linux bind mount omits "bind" option? #1717

mpuncel opened this issue Feb 11, 2018 · 1 comment

Comments

@mpuncel
Copy link

mpuncel commented Feb 11, 2018

I recently was attempting to modify the standard generated config.json file to add a bind mount to the readonly rootfs for my container.

I added a mount that looked like the below, based on the fact that

$ mount --bind /var/log/foo /path/to/rootfs/var/log/foo

worked the way I wanted it to:

{
        "destination": "/var/log/foo",
        "type": "bind",
        "source": "/var/log/foo",
        "options": [
                "nosuid",
                "nodev",
                "strictatime"
        ]
}

However I got the following error:

2018-02-09_22:04:23.06490 container_linux.go:265: starting container process caused "process_linux.go:348: container init caused \"rootfs_linux.go:57: mounting \\\"/var/log/foo\\\" to rootfs \\\"/path/to/rootfs\\\" at \\\"/path/to/rootfs/var/log/foo\\\" caused \\\"no such device\\\"\""

I wasn't able to find the issue until I 1) used strace on my mount --bind call to see that the MS_BIND flag was being passed to the mount() syscall, and 2) added print debugging to runc to see that the unix.MS_BIND flag was not being sent. This led me to adding the "bind" option and it started working!

I'm not sure if this would have been obvious to others, but I'm wondering if runc should either add the flag for the user if it's missing or report clearer error feedback when the bind type is used without the bind option? I'm also not sure if there's a case where that behavior would be desired?

@cyphar
Copy link
Member

cyphar commented Feb 11, 2018

I think "type": "bind" is a mistake in the way that we handle stuff in runc. In reality, bind-mount types are ignored by the mount(2) syscall so we shouldn't be looking at that field at all.

But if we're going to have special-casing for bind (which we do in rootfs_linux.go unfortunately) then we should at least make sure that we special case things properly, and give warnings if users are making common mistakes (I've made this mistake a few times as well).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants