From a814785a52d63eef0e6261c1e009b598199585dd Mon Sep 17 00:00:00 2001 From: "hiroto.toyoda" Date: Sat, 20 Dec 2025 15:46:39 +0900 Subject: [PATCH] fix: avoid setting timeout when waitTimeout is not positive Signed-off-by: hiroto.toyoda --- cmd/compose/start.go | 5 ++++- cmd/compose/up.go | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/cmd/compose/start.go b/cmd/compose/start.go index a2bb05797c..bd5f10c463 100644 --- a/cmd/compose/start.go +++ b/cmd/compose/start.go @@ -63,7 +63,10 @@ func runStart(ctx context.Context, dockerCli command.Cli, backendOptions *Backen return err } - timeout := time.Duration(opts.waitTimeout) * time.Second + var timeout time.Duration + if opts.waitTimeout > 0 { + timeout = time.Duration(opts.waitTimeout) * time.Second + } return backend.Start(ctx, name, api.StartOptions{ AttachTo: services, Project: project, diff --git a/cmd/compose/up.go b/cmd/compose/up.go index 5819900823..cda2678bbb 100644 --- a/cmd/compose/up.go +++ b/cmd/compose/up.go @@ -188,6 +188,9 @@ func upCommand(p *ProjectOptions, dockerCli command.Cli, backendOptions *Backend //nolint:gocyclo func validateFlags(up *upOptions, create *createOptions) error { + if up.waitTimeout < 0 { + return fmt.Errorf("--wait-timeout must be a non-negative integer") + } if up.exitCodeFrom != "" && !up.cascadeFail { up.cascadeStop = true } @@ -328,7 +331,10 @@ func runUp( attach = attachSet.Elements() } - timeout := time.Duration(upOptions.waitTimeout) * time.Second + var timeout time.Duration + if upOptions.waitTimeout > 0 { + timeout = time.Duration(upOptions.waitTimeout) * time.Second + } return backend.Up(ctx, project, api.UpOptions{ Create: create, Start: api.StartOptions{