mirror of
https://github.com/containers/podman.git
synced 2025-06-18 15:39:08 +08:00
Merge pull request #3315 from giuseppe/support-bind-nonrecursive
storage: support --mount type=bind,bind-nonrecursive
This commit is contained in:
@ -458,6 +458,7 @@ Current supported mount TYPES are bind, and tmpfs.
|
|||||||
Options specific to bind:
|
Options specific to bind:
|
||||||
|
|
||||||
· bind-propagation: shared, slave, private, rshared, rslave, or rprivate(default). See also mount(2).
|
· bind-propagation: shared, slave, private, rshared, rslave, or rprivate(default). See also mount(2).
|
||||||
|
. bind-nonrecursive: do not setup a recursive bind mount. By default it is recursive.
|
||||||
|
|
||||||
Options specific to tmpfs:
|
Options specific to tmpfs:
|
||||||
|
|
||||||
|
@ -471,6 +471,7 @@ Current supported mount TYPES are bind, and tmpfs.
|
|||||||
Options specific to bind:
|
Options specific to bind:
|
||||||
|
|
||||||
· bind-propagation: Z, z, shared, slave, private, rshared, rslave, or rprivate(default). See also mount(2).
|
· bind-propagation: Z, z, shared, slave, private, rshared, rslave, or rprivate(default). See also mount(2).
|
||||||
|
. bind-nonrecursive: do not setup a recursive bind mount. By default it is recursive.
|
||||||
|
|
||||||
Options specific to tmpfs:
|
Options specific to tmpfs:
|
||||||
|
|
||||||
|
@ -384,7 +384,7 @@ func (config *CreateConfig) getMounts() (map[string]spec.Mount, map[string]*libp
|
|||||||
}
|
}
|
||||||
finalNamedVolumes[volume.Dest] = volume
|
finalNamedVolumes[volume.Dest] = volume
|
||||||
default:
|
default:
|
||||||
return nil, nil, errors.Errorf("invalid fylesystem type %q", kv[1])
|
return nil, nil, errors.Errorf("invalid filesystem type %q", kv[1])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,6 +403,8 @@ func getBindMount(args []string) (spec.Mount, error) {
|
|||||||
for _, val := range args {
|
for _, val := range args {
|
||||||
kv := strings.Split(val, "=")
|
kv := strings.Split(val, "=")
|
||||||
switch kv[0] {
|
switch kv[0] {
|
||||||
|
case "bind-nonrecursive":
|
||||||
|
newMount.Options = append(newMount.Options, "bind")
|
||||||
case "ro", "nosuid", "nodev", "noexec":
|
case "ro", "nosuid", "nodev", "noexec":
|
||||||
// TODO: detect duplication of these options.
|
// TODO: detect duplication of these options.
|
||||||
// (Is this necessary?)
|
// (Is this necessary?)
|
||||||
@ -574,7 +576,7 @@ func ValidateVolumeCtrDir(ctrDir string) error {
|
|||||||
|
|
||||||
// ValidateVolumeOpts validates a volume's options
|
// ValidateVolumeOpts validates a volume's options
|
||||||
func ValidateVolumeOpts(options []string) error {
|
func ValidateVolumeOpts(options []string) error {
|
||||||
var foundRootPropagation, foundRWRO, foundLabelChange int
|
var foundRootPropagation, foundRWRO, foundLabelChange, bindType int
|
||||||
for _, opt := range options {
|
for _, opt := range options {
|
||||||
switch opt {
|
switch opt {
|
||||||
case "rw", "ro":
|
case "rw", "ro":
|
||||||
@ -592,6 +594,11 @@ func ValidateVolumeOpts(options []string) error {
|
|||||||
if foundRootPropagation > 1 {
|
if foundRootPropagation > 1 {
|
||||||
return errors.Errorf("invalid options %q, can only specify 1 '[r]shared', '[r]private' or '[r]slave' option", strings.Join(options, ", "))
|
return errors.Errorf("invalid options %q, can only specify 1 '[r]shared', '[r]private' or '[r]slave' option", strings.Join(options, ", "))
|
||||||
}
|
}
|
||||||
|
case "bind", "rbind":
|
||||||
|
bindType++
|
||||||
|
if bindType > 1 {
|
||||||
|
return errors.Errorf("invalid options %q, can only specify 1 '[r]bind' option", strings.Join(options, ", "))
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return errors.Errorf("invalid option type %q", opt)
|
return errors.Errorf("invalid option type %q", opt)
|
||||||
}
|
}
|
||||||
|
@ -17,10 +17,19 @@ var (
|
|||||||
// sensible and follow convention.
|
// sensible and follow convention.
|
||||||
func ProcessOptions(options []string) []string {
|
func ProcessOptions(options []string) []string {
|
||||||
var (
|
var (
|
||||||
foundrw, foundro bool
|
foundbind, foundrw, foundro bool
|
||||||
rootProp string
|
rootProp string
|
||||||
)
|
)
|
||||||
options = append(options, "rbind")
|
for _, opt := range options {
|
||||||
|
switch opt {
|
||||||
|
case "bind", "rbind":
|
||||||
|
foundbind = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !foundbind {
|
||||||
|
options = append(options, "rbind")
|
||||||
|
}
|
||||||
for _, opt := range options {
|
for _, opt := range options {
|
||||||
switch opt {
|
switch opt {
|
||||||
case "rw":
|
case "rw":
|
||||||
|
@ -659,6 +659,14 @@ USER mail`
|
|||||||
Expect(isSharedOnly).Should(BeTrue())
|
Expect(isSharedOnly).Should(BeTrue())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman run --mount type=bind,bind-nonrecursive", func() {
|
||||||
|
SkipIfRootless()
|
||||||
|
session := podmanTest.Podman([]string{"run", "--mount", "type=bind,bind-nonrecursive,slave,src=/,target=/host", fedoraMinimal, "findmnt", "-nR", "/host"})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
Expect(len(session.OutputToStringArray())).To(Equal(1))
|
||||||
|
})
|
||||||
|
|
||||||
It("podman run --pod automatically", func() {
|
It("podman run --pod automatically", func() {
|
||||||
session := podmanTest.Podman([]string{"run", "--pod", "new:foobar", ALPINE, "ls"})
|
session := podmanTest.Podman([]string{"run", "--pod", "new:foobar", ALPINE, "ls"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
|
Reference in New Issue
Block a user