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

Fix comment lines about the default mount propagation #159

Merged
merged 1 commit into from
Feb 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions libdocker/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,23 @@ func GenerateMountBindings(mounts []*v1.Mount, terminationMessagePath string) []
}
switch m.Propagation {
case v1.MountPropagation_PROPAGATION_PRIVATE:
// noop, private is default
// noop, dockerd will decide the propagation.
//
// dockerd's default propagation is "rprivate": https:/moby/moby/blob/v20.10.23/volume/mounts/linux_parser.go#L145
//
// However, dockerd automatically changes the default propagation to "rslave"
// when the mount source contains the daemon root (/var/lib/docker):
// - https:/moby/moby/blob/v20.10.23/daemon/volumes.go#L137-L143
// - https:/moby/moby/blob/v20.10.23/daemon/volumes_linux.go#L11-L36
//
// This behavior was introduced in Docker 18.03: https:/moby/moby/pull/36055
case v1.MountPropagation_PROPAGATION_BIDIRECTIONAL:
attrs = append(attrs, "rshared")
case v1.MountPropagation_PROPAGATION_HOST_TO_CONTAINER:
attrs = append(attrs, "rslave")
default:
logrus.Infof("Unknown propagation mode for hostPath %s", m.HostPath)
// Falls back to "private"
// let dockerd decide the propagation
}

if len(attrs) > 0 {
Expand Down