From 745fa04e521f84ce09658008ae24227ca57c2f49 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Sat, 23 Feb 2019 23:53:28 +0900 Subject: [PATCH] service: support --mount type=bind,bind-nonrecursive Signed-off-by: Akihiro Suda --- daemon/cluster/convert/container.go | 11 +++++++---- daemon/cluster/executor/container/container.go | 4 +++- docs/api/version-history.md | 1 + 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/daemon/cluster/convert/container.go b/daemon/cluster/convert/container.go index 9e5b6ee641..7f1e0af22c 100644 --- a/daemon/cluster/convert/container.go +++ b/daemon/cluster/convert/container.go @@ -78,7 +78,8 @@ func containerSpecFromGRPC(c *swarmapi.ContainerSpec) *types.ContainerSpec { if m.BindOptions != nil { mount.BindOptions = &mounttypes.BindOptions{ - Propagation: mounttypes.Propagation(strings.ToLower(swarmapi.Mount_BindOptions_MountPropagation_name[int32(m.BindOptions.Propagation)])), + Propagation: mounttypes.Propagation(strings.ToLower(swarmapi.Mount_BindOptions_MountPropagation_name[int32(m.BindOptions.Propagation)])), + NonRecursive: m.BindOptions.NonRecursive, } } @@ -331,9 +332,11 @@ func containerToGRPC(c *types.ContainerSpec) (*swarmapi.ContainerSpec, error) { } if m.BindOptions.NonRecursive { - // TODO(AkihiroSuda): NonRecursive is unsupported for Swarm-mode now because of mutual vendoring - // across moby and swarmkit. Will be available soon after the moby PR gets merged. - return nil, fmt.Errorf("invalid NonRecursive: %q", m.BindOptions.Propagation) + if mount.BindOptions == nil { + // the propagation defaults to rprivate + mount.BindOptions = &swarmapi.Mount_BindOptions{} + } + mount.BindOptions.NonRecursive = m.BindOptions.NonRecursive } } diff --git a/daemon/cluster/executor/container/container.go b/daemon/cluster/executor/container/container.go index 8ad12d6e5d..48d6aaa83c 100644 --- a/daemon/cluster/executor/container/container.go +++ b/daemon/cluster/executor/container/container.go @@ -281,7 +281,9 @@ func convertMount(m api.Mount) enginemount.Mount { } if m.BindOptions != nil { - mount.BindOptions = &enginemount.BindOptions{} + mount.BindOptions = &enginemount.BindOptions{ + NonRecursive: m.BindOptions.NonRecursive, + } switch m.BindOptions.Propagation { case api.MountPropagationRPrivate: mount.BindOptions.Propagation = enginemount.PropagationRPrivate diff --git a/docs/api/version-history.md b/docs/api/version-history.md index d675fd7479..042aa2771f 100644 --- a/docs/api/version-history.md +++ b/docs/api/version-history.md @@ -17,6 +17,7 @@ keywords: "API, Docker, rcli, REST, documentation" [Docker Engine API v1.41](https://docs.docker.com/engine/api/v1.41/) documentation +* `POST /services/create` and `POST /services/{id}/update` now supports `BindOptions.NonRecursive`. * The `ClusterStore` and `ClusterAdvertise` fields in `GET /info` are deprecated and are now omitted if they contain an empty value. This change is not versioned, and affects all API versions if the daemon has this patch.