Skip to content

Commit 035276e

Browse files
authored
watch: add warning when a path is already used by a bind mount volume (docker#10741)
Signed-off-by: Guillaume Lours <[email protected]>
1 parent db24023 commit 035276e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pkg/compose/watch.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ func (s *composeService) Watch(ctx context.Context, project *types.Project, serv
143143

144144
var paths []string
145145
for _, trigger := range config.Watch {
146+
if checkIfPathAlreadyBindMounted(trigger.Path, service.Volumes) {
147+
logrus.Warnf("path '%s' also declared by a bind mount volume, this path won't be monitored!\n", trigger.Path)
148+
continue
149+
}
146150
paths = append(paths, trigger.Path)
147151
}
148152

@@ -383,3 +387,12 @@ func debounce(ctx context.Context, clock clockwork.Clock, delay time.Duration, i
383387
}
384388
}
385389
}
390+
391+
func checkIfPathAlreadyBindMounted(watchPath string, volumes []types.ServiceVolumeConfig) bool {
392+
for _, volume := range volumes {
393+
if volume.Bind != nil && strings.HasPrefix(watchPath, volume.Source) {
394+
return true
395+
}
396+
}
397+
return false
398+
}

0 commit comments

Comments
 (0)