docker/compose · error
--abort-on-container-failure cannot be combined with --abort
Error message
--abort-on-container-failure cannot be combined with --abort-on-container-exit
What it means
Returned by validateFlags for `docker compose up` when both cascade-stop behaviors are enabled. --abort-on-container-exit sets cascadeStop; --abort-on-container-failure sets cascadeFail. Note the implicit link: passing --exit-code-from without --abort-on-container-failure also sets cascadeStop, so combining `--exit-code-from svc --abort-on-container-failure` triggers this error too. The two abort semantics (stop on ANY exit vs. stop only on failure) are mutually exclusive.
Source
Thrown at cmd/compose/up.go:198
if name == "y" {
logrus.Warn("--y is deprecated, please use --yes instead")
name = "yes"
}
return pflag.NormalizedName(name)
})
return upCmd
}
//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
}
if up.cascadeStop && up.cascadeFail {
return fmt.Errorf("--abort-on-container-failure cannot be combined with --abort-on-container-exit")
}
if up.wait {
if up.attachDependencies || up.cascadeStop || len(up.attach) > 0 {
return fmt.Errorf("--wait cannot be combined with --abort-on-container-exit, --attach or --attach-dependencies")
}
up.Detach = true
}
if create.Build && create.noBuild {
return fmt.Errorf("--build and --no-build are incompatible")
}
if up.Detach && (up.attachDependencies || up.cascadeStop || up.cascadeFail || len(up.attach) > 0 || up.watch) {
if up.wait {
return fmt.Errorf("--wait cannot be combined with --abort-on-container-exit, --abort-on-container-failure, --attach, --attach-dependencies or --watch")
} else {
return fmt.Errorf("--detach cannot be combined with --abort-on-container-exit, --abort-on-container-failure, --attach, --attach-dependencies or --watch")
}
}
if create.noInherit && create.noRecreate {View on GitHub (pinned to ddc4b044b6)
Solutions
- Keep exactly one abort mode: use `--abort-on-container-failure --exit-code-from web` (recommended for CI, stops only on failure), dropping --abort-on-container-exit.
- Or keep `--abort-on-container-exit --exit-code-from web` and drop --abort-on-container-failure.
- Audit wrapper scripts/Makefiles that concatenate COMPOSE_UP_FLAGS from multiple variables.
Example fix
# before docker compose up --abort-on-container-exit --abort-on-container-failure --exit-code-from web # after docker compose up --abort-on-container-failure --exit-code-from web
Defensive patterns
Strategy: validation
Validate before calling
# allow exactly one abort mode in CI wrappers
ABORT_FLAGS=$(echo "$UP_FLAGS" | grep -o -- '--abort-on-container-[a-z]*' | sort -u)
[ "$(wc -l <<<"$ABORT_FLAGS")" -gt 1 ] && { echo 'conflicting abort flags' >&2; exit 2; }
docker compose up $UP_FLAGS Prevention
- Standardize CI on --abort-on-container-failure --exit-code-from X.
- Know --exit-code-from implies abort-on-container-exit semantics.
- Build flag strings from one mutually exclusive choice, not independent toggles.
When it happens
Trigger: `docker compose up --abort-on-container-exit --abort-on-container-failure`; or `docker compose up --exit-code-from web --abort-on-container-failure` (exit-code-from implies cascadeStop when cascadeFail is not already set, then the explicit flag makes both true).
Common situations: CI configs accumulating flags over time until two abort modes coexist; copying flag sets between docs/versions; users assuming --exit-code-from is independent of the abort flags.
Related errors
- --wait-timeout must be a non-negative integer
- --wait cannot be combined with --abort-on-container-exit, --
- --build and --no-build are incompatible
- --wait cannot be combined with --abort-on-container-exit, --
- --detach cannot be combined with --abort-on-container-exit,
AI-assisted analysis of docker/compose@ddc4b044b6 (2026-08-15).
Data as JSON: /api/errors/ac2ebb51c0ef8143.
Report an issue: GitHub.