Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion opts/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (m *MountOpt) Set(value string) error {
case "bind-recursive":
switch val {
case "enabled": // read-only mounts are recursively read-only if Engine >= v25 && kernel >= v5.12, otherwise writable
// NOP
ensureBindOptions(&mount)
case "disabled": // previously "bind-nonrecursive=true"
ensureBindOptions(&mount).NonRecursive = true
case "writable": // conforms to the default read-only bind-mount of Docker v24; read-only mounts are recursively mounted but not recursively read-only
Expand Down
27 changes: 24 additions & 3 deletions opts/mount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,26 @@ func TestMountOptErrors(t *testing.T) {
value: "type=bind,target=/foo,source=/foo,volume-nocopy=true",
expErr: "cannot mix 'volume-*' options with mount type 'bind'",
},
{
doc: "bind-recursive enabled with volume",
value: "type=volume,target=/foo,bind-recursive=enabled",
expErr: "cannot mix 'bind-*' options with mount type 'volume'",
},
{
doc: "bind-recursive enabled with default mount type",
value: "target=/foo,bind-recursive=enabled",
expErr: "cannot mix 'bind-*' options with mount type 'volume'",
},
{
doc: "bind-recursive enabled with tmpfs",
value: "type=tmpfs,target=/foo,bind-recursive=enabled",
expErr: "cannot mix 'bind-*' options with mount type 'tmpfs'",
},
{
doc: "bind-recursive enabled before image type",
value: "bind-recursive=enabled,type=image,source=alpine,target=/foo",
expErr: "cannot mix 'bind-*' options with mount type 'image'",
},
}

for _, tc := range tests {
Expand Down Expand Up @@ -525,9 +545,10 @@ func TestMountOptSetBindRecursive(t *testing.T) {
assert.NilError(t, m.Set("type=bind,source=/foo,target=/bar,bind-recursive=enabled"))
assert.Check(t, is.DeepEqual([]mount.Mount{
{
Type: mount.TypeBind,
Source: "/foo",
Target: "/bar",
Type: mount.TypeBind,
Source: "/foo",
Target: "/bar",
BindOptions: &mount.BindOptions{},
},
}, m.Value()))
})
Expand Down