Skip to content

Add wait-timeout option to docker-compose up #12702

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Dustin4444
Copy link

@Dustin4444 Dustin4444 commented Apr 3, 2025

Fixes #10269

Add --wait-timeout option to docker-compose up command to prevent waiting indefinitely for a service to become healthy.

  • Documentation

    • Add documentation for --wait-timeout option in docs/reference/compose_up.md
    • Explain the purpose of --wait-timeout option
    • Provide an example usage of --wait-timeout option
  • Command Implementation

    • Add waitTimeout field to upOptions struct in cmd/compose/up.go
    • Add --wait-timeout flag to upCommand function
    • Validate --wait-timeout flag in validateFlags function
    • Pass waitTimeout to runUp function
    • Update runUp function to handle waitTimeout
  • Command Logic

    • Add waitTimeout parameter to UpOptions struct in pkg/compose/up.go
    • Update Up function to handle waitTimeout
    • Implement timeout logic in Up function
    • Ensure waitTimeout is respected during Up execution
  • Wait Command

    • Add waitTimeout parameter to waitOptions struct in cmd/compose/wait.go
    • Add --wait-timeout flag to waitCommand function
    • Pass waitTimeout to runWait function
    • Update runWait function to handle waitTimeout
  • Wait Logic

    • Add waitTimeout parameter to WaitOptions struct in pkg/compose/wait.go
    • Update Wait function to handle waitTimeout
    • Implement timeout logic in Wait function
    • Ensure waitTimeout is respected during Wait execution

For more details, open the Copilot Workspace session.

Fixes docker#10269

Add `--wait-timeout` option to `docker-compose up` command to prevent waiting indefinitely for a service to become healthy.

* **Documentation**
  - Add documentation for `--wait-timeout` option in `docs/reference/compose_up.md`
  - Explain the purpose of `--wait-timeout` option
  - Provide an example usage of `--wait-timeout` option

* **Command Implementation**
  - Add `waitTimeout` field to `upOptions` struct in `cmd/compose/up.go`
  - Add `--wait-timeout` flag to `upCommand` function
  - Validate `--wait-timeout` flag in `validateFlags` function
  - Pass `waitTimeout` to `runUp` function
  - Update `runUp` function to handle `waitTimeout`

* **Command Logic**
  - Add `waitTimeout` parameter to `UpOptions` struct in `pkg/compose/up.go`
  - Update `Up` function to handle `waitTimeout`
  - Implement timeout logic in `Up` function
  - Ensure `waitTimeout` is respected during `Up` execution

* **Wait Command**
  - Add `waitTimeout` parameter to `waitOptions` struct in `cmd/compose/wait.go`
  - Add `--wait-timeout` flag to `waitCommand` function
  - Pass `waitTimeout` to `runWait` function
  - Update `runWait` function to handle `waitTimeout`

* **Wait Logic**
  - Add `waitTimeout` parameter to `WaitOptions` struct in `pkg/compose/wait.go`
  - Update `Wait` function to handle `waitTimeout`
  - Implement timeout logic in `Wait` function
  - Ensure `waitTimeout` is respected during `Wait` execution

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/docker/compose/issues/10269?shareId=XXXX-XXXX-XXXX-XXXX).
@Dustin4444 Dustin4444 requested a review from a team as a code owner April 3, 2025 03:34
@Dustin4444 Dustin4444 requested review from ndeloof and glours April 3, 2025 03:34
@glours
Copy link
Contributor

glours commented Apr 3, 2025

Hey @Dustin4444

Can you explain the purpose of this PR? I mean you tried to fix an issue that was already address with a flag already present in the up command 🤔

$ docker compose up --help                                                                                                                                                                              07:58:19
Usage:  docker compose up [OPTIONS] [SERVICE...]

Create and start containers

Options:
      --abort-on-container-exit      Stops all containers if any container was stopped. Incompatible with -d
      --abort-on-container-failure   Stops all containers if any container exited with failure. Incompatible with -d
      --always-recreate-deps         Recreate dependent containers. Incompatible with --no-recreate.
      --attach stringArray           Restrict attaching to the specified services. Incompatible with --attach-dependencies.
      --attach-dependencies          Automatically attach to log output of dependent services
      --build                        Build images before starting containers
  -d, --detach                       Detached mode: Run containers in the background
      --dry-run                      Execute command in dry run mode
      --exit-code-from string        Return the exit code of the selected service container. Implies --abort-on-container-exit
      --force-recreate               Recreate containers even if their configuration and image haven't changed
      --menu                         Enable interactive shortcuts when running attached. Incompatible with --detach. Can also be enable/disable by setting COMPOSE_MENU environment var.
      --no-attach stringArray        Do not attach (stream logs) to the specified services
      --no-build                     Don't build an image, even if it's policy
      --no-color                     Produce monochrome output
      --no-deps                      Don't start linked services
      --no-log-prefix                Don't print prefix in logs
      --no-recreate                  If containers already exist, don't recreate them. Incompatible with --force-recreate.
      --no-start                     Don't start the services after creating them
      --pull string                  Pull image before running ("always"|"missing"|"never") (default "policy")
      --quiet-pull                   Pull without printing progress information
      --remove-orphans               Remove containers for services not defined in the Compose file
  -V, --renew-anon-volumes           Recreate anonymous volumes instead of retrieving data from the previous containers
      --scale scale                  Scale SERVICE to NUM instances. Overrides the scale setting in the Compose file if present.
  -t, --timeout int                  Use this timeout in seconds for container shutdown when attached or when containers are already running
      --timestamps                   Show timestamps
      --wait                         Wait for services to be running|healthy. Implies detached mode.
      --wait-timeout int             Maximum duration in seconds to wait for the project to be running|healthy
  -w, --watch                        Watch source code and rebuild/refresh containers when files are updated.
  -y, --yes                          Assume "yes" as answer to all prompts and run non-interactively

@Dustin4444 Dustin4444 marked this pull request as draft April 4, 2025 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add timeout to --wait option
2 participants