Skip to content

Commit c37182b

Browse files
authored
Merge pull request docker#10090 from milas/fix-wcow-volume
volume: fix WCOW volume mounts
2 parents 0eaa249 + ffb9544 commit c37182b

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

pkg/compose/create.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ func (s *composeService) getCreateOptions(ctx context.Context, p *types.Project,
260260
stdinOpen = service.StdinOpen
261261
)
262262

263-
volumeMounts, binds, mounts, err := s.buildContainerVolumes(ctx, *p, service, inherit)
263+
binds, mounts, err := s.buildContainerVolumes(ctx, *p, service, inherit)
264264
if err != nil {
265265
return nil, nil, nil, err
266266
}
@@ -289,7 +289,6 @@ func (s *composeService) getCreateOptions(ctx context.Context, p *types.Project,
289289
StopSignal: service.StopSignal,
290290
Env: ToMobyEnv(env),
291291
Healthcheck: ToMobyHealthCheck(service.HealthCheck),
292-
Volumes: volumeMounts,
293292
StopTimeout: ToSeconds(service.StopGracePeriod),
294293
}
295294

@@ -731,30 +730,32 @@ func getDependentServiceFromMode(mode string) string {
731730
return ""
732731
}
733732

734-
func (s *composeService) buildContainerVolumes(ctx context.Context, p types.Project, service types.ServiceConfig,
735-
inherit *moby.Container) (map[string]struct{}, []string, []mount.Mount, error) {
736-
var mounts = []mount.Mount{}
733+
func (s *composeService) buildContainerVolumes(
734+
ctx context.Context,
735+
p types.Project,
736+
service types.ServiceConfig,
737+
inherit *moby.Container,
738+
) ([]string, []mount.Mount, error) {
739+
var mounts []mount.Mount
740+
var binds []string
737741

738742
image := api.GetImageNameOrDefault(service, p.Name)
739743
imgInspect, _, err := s.apiClient().ImageInspectWithRaw(ctx, image)
740744
if err != nil {
741-
return nil, nil, nil, err
745+
return nil, nil, err
742746
}
743747

744748
mountOptions, err := buildContainerMountOptions(p, service, imgInspect, inherit)
745749
if err != nil {
746-
return nil, nil, nil, err
750+
return nil, nil, err
747751
}
748752

749-
volumeMounts := map[string]struct{}{}
750-
binds := []string{}
751753
MOUNTS:
752754
for _, m := range mountOptions {
753755
if m.Type == mount.TypeNamedPipe {
754756
mounts = append(mounts, m)
755757
continue
756758
}
757-
volumeMounts[m.Target] = struct{}{}
758759
if m.Type == mount.TypeBind {
759760
// `Mount` is preferred but does not offer option to created host path if missing
760761
// so `Bind` API is used here with raw volume string
@@ -774,7 +775,7 @@ MOUNTS:
774775
}
775776
mounts = append(mounts, m)
776777
}
777-
return volumeMounts, binds, mounts, nil
778+
return binds, mounts, nil
778779
}
779780

780781
func buildContainerMountOptions(p types.Project, s types.ServiceConfig, img moby.ImageInspect, inherit *moby.Container) ([]mount.Mount, error) {

0 commit comments

Comments
 (0)