From 0c1a691fa5b9b4a68ae00bf9d4b5120a1e2b87b4 Mon Sep 17 00:00:00 2001 From: Nicolas De loof Date: Tue, 9 May 2023 21:15:40 +0200 Subject: [PATCH] fix container being recreated while config has not changed (#10540) Signed-off-by: Nicolas De Loof --- cmd/compose/compose.go | 4 ++-- cmd/compose/run.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/compose/compose.go b/cmd/compose/compose.go index 397cccda6..5f16f7916 100644 --- a/cmd/compose/compose.go +++ b/cmd/compose/compose.go @@ -119,7 +119,7 @@ func (o *ProjectOptions) WithProject(fn ProjectFunc) func(cmd *cobra.Command, ar // WithServices creates a cobra run command from a ProjectFunc based on configured project options and selected services func (o *ProjectOptions) WithServices(fn ProjectServicesFunc) func(cmd *cobra.Command, args []string) error { return Adapt(func(ctx context.Context, args []string) error { - project, err := o.ToProject(args, cli.WithResolvedPaths(true)) + project, err := o.ToProject(args, cli.WithResolvedPaths(true), cli.WithDiscardEnvFile) if err != nil { return err } @@ -143,7 +143,7 @@ func (o *ProjectOptions) projectOrName(services ...string) (*types.Project, stri name := o.ProjectName var project *types.Project if len(o.ConfigPaths) > 0 || o.ProjectName == "" { - p, err := o.ToProject(services) + p, err := o.ToProject(services, cli.WithDiscardEnvFile) if err != nil { envProjectName := os.Getenv("COMPOSE_PROJECT_NAME") if envProjectName != "" { diff --git a/cmd/compose/run.go b/cmd/compose/run.go index 5fbbac76e..f454ac36d 100644 --- a/cmd/compose/run.go +++ b/cmd/compose/run.go @@ -142,7 +142,7 @@ func runCommand(p *ProjectOptions, streams api.Streams, backend api.Service) *co return nil }), RunE: Adapt(func(ctx context.Context, args []string) error { - project, err := p.ToProject([]string{opts.Service}, cgo.WithResolvedPaths(true)) + project, err := p.ToProject([]string{opts.Service}, cgo.WithResolvedPaths(true), cgo.WithDiscardEnvFile) if err != nil { return err }