-
Notifications
You must be signed in to change notification settings - Fork 609
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
Support bind propagation options for --volume
#268
Conversation
pkg/mountutil/mountutil.go
Outdated
default: | ||
return nil, errors.Errorf("failed to parse %q", s) | ||
} | ||
res.Mount = specs.Mount{ | ||
Type: "none", | ||
Type: "bind", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this is how docker does. But TIL runc ignores this for bind mounts.
if flags&unix.MS_BIND != 0 {
// Any "type" the user specified is meaningless (and ignored) for
// bind-mounts -- so we set it to "bind" because rootfs_linux.go
// (incorrectly) relies on this for some checks.
device = "bind"
if !filepath.IsAbs(source) {
source = filepath.Join(cwd, m.Source)
}
}
Reverted this to "none"
.
pkg/mountutil/mountutil_linux.go
Outdated
// the mountpoint can be a slave of the host mount. | ||
specOpts = append(specOpts, func(ctx context.Context, cli oci.Client, c *containers.Container, s *oci.Spec) error { | ||
rootpg := s.Linux.RootfsPropagation | ||
if rootpg != "shared" && rootpg != "rshared" && rootpg != "slave" && rootpg != "rslave" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use switch{}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks
Signed-off-by: Kohei Tokunaga <[email protected]>
Fixes #261
This PR adds the following docker-compatible propagation option to bind mounts:
shared
: The host and the container share mount events in the bind mount each other.slave
: The container receives mount events in the bind mount from the host. But the host doesn't receive events from the container.private
: Mount events in the bind mount doesn't propagate each other.rshared
: Similar asshared
but the propagation type is applied to all mounts under the bind mount.rslave
: Similar asslave
but the propagation type is applied to all mounts under the bind mount.rprivate
(default): Similar asprivate
but the propagation type is applied to all mounts under the bind mount.For more details about propagation, please see also shared subtree document of linux kernel.