Remove bind options when creating a volume type

Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
This commit is contained in:
Joana Hrotko 2024-10-01 15:07:44 +01:00 committed by Nicolas De loof
parent 3ef5045a08
commit 41df35c1f4
1 changed files with 2 additions and 7 deletions

View File

@ -1067,7 +1067,7 @@ func buildMount(project types.Project, volume types.ServiceVolumeConfig) (mount.
} }
} }
bind, vol, tmpfs := buildMountOptions(project, volume) bind, vol, tmpfs := buildMountOptions(volume)
volume.Target = path.Clean(volume.Target) volume.Target = path.Clean(volume.Target)
@ -1087,7 +1087,7 @@ func buildMount(project types.Project, volume types.ServiceVolumeConfig) (mount.
}, nil }, nil
} }
func buildMountOptions(project types.Project, volume types.ServiceVolumeConfig) (*mount.BindOptions, *mount.VolumeOptions, *mount.TmpfsOptions) { func buildMountOptions(volume types.ServiceVolumeConfig) (*mount.BindOptions, *mount.VolumeOptions, *mount.TmpfsOptions) {
switch volume.Type { switch volume.Type {
case "bind": case "bind":
if volume.Volume != nil { if volume.Volume != nil {
@ -1104,11 +1104,6 @@ func buildMountOptions(project types.Project, volume types.ServiceVolumeConfig)
if volume.Tmpfs != nil { if volume.Tmpfs != nil {
logrus.Warnf("mount of type `volume` should not define `tmpfs` option") logrus.Warnf("mount of type `volume` should not define `tmpfs` option")
} }
if v, ok := project.Volumes[volume.Source]; ok && v.DriverOpts["o"] == types.VolumeTypeBind {
return buildBindOption(&types.ServiceVolumeBind{
CreateHostPath: true,
}), nil, nil
}
return nil, buildVolumeOptions(volume.Volume), nil return nil, buildVolumeOptions(volume.Volume), nil
case "tmpfs": case "tmpfs":
if volume.Bind != nil { if volume.Bind != nil {