diff --git a/pkg/compose/watch.go b/pkg/compose/watch.go index 72f329a6252..fd8a61ebd4f 100644 --- a/pkg/compose/watch.go +++ b/pkg/compose/watch.go @@ -353,8 +353,11 @@ func loadDevelopmentConfig(service types.ServiceConfig, project *types.Project) func checkIfPathAlreadyBindMounted(watchPath string, volumes []types.ServiceVolumeConfig) bool { for _, volume := range volumes { - if volume.Bind != nil && strings.HasPrefix(watchPath, volume.Source) { - return true + if volume.Bind != nil { + relPath, err := filepath.Rel(volume.Source, watchPath) + if err == nil && !strings.HasPrefix(relPath, "..") { + return true + } } } return false diff --git a/pkg/e2e/fixtures/watch/compose.yaml b/pkg/e2e/fixtures/watch/compose.yaml index 5c26ee0fdb7..7e5e0d28bf4 100644 --- a/pkg/e2e/fixtures/watch/compose.yaml +++ b/pkg/e2e/fixtures/watch/compose.yaml @@ -37,4 +37,7 @@ services: RUN mkdir -p /app/config init: true command: sleep infinity + volumes: + - ./dat:/app/dat + - ./data-logs:/app/data-logs develop: *x-dev diff --git a/pkg/e2e/fixtures/watch/dat/meow.dat b/pkg/e2e/fixtures/watch/dat/meow.dat new file mode 100644 index 00000000000..0dd3d19a01d --- /dev/null +++ b/pkg/e2e/fixtures/watch/dat/meow.dat @@ -0,0 +1 @@ +i am a wannabe cat diff --git a/pkg/e2e/fixtures/watch/data-logs/server.log b/pkg/e2e/fixtures/watch/data-logs/server.log new file mode 100644 index 00000000000..b6b65a681d9 --- /dev/null +++ b/pkg/e2e/fixtures/watch/data-logs/server.log @@ -0,0 +1 @@ +[INFO] Server started successfully on port 8080