docker/cli · error

conflicting options: --no-pause and --pause cannot be used…

Error message

conflicting options: --no-pause and --pause cannot be used together

What it means

newCommitCommand (cli/command/container/commit.go:28) wires both --pause/-p and --no-pause flags. In RunE at line 40-43, if the user explicitly set --pause AND explicitly set --no-pause, it returns errors.New("conflicting options: --no-pause and --pause cannot be used together"). These flags are logical opposites (pause vs. don't pause the container during commit); --pause is also deprecated in favor of --no-pause.

Solutions

  1. Use only --no-pause (the current recommended flag) to disable pausing; pausing is the default, so to pause just omit the flag.
  2. Remove any deprecated --pause/-p from your alias or command.
  3. Note --pause is deprecated since v29 and slated for removal; migrate to --no-pause.

Example fix

# before
docker commit --pause --no-pause web myimg
# after — pausing is default; use --no-pause only to disable it
docker commit web myimg
# or to explicitly not pause
docker commit --no-pause web myimg
Defensive patterns

Strategy: validation

Validate before calling

// In a wrapper, reject the combination before invoking docker:
if hasPause && hasNoPause {
    return errors.New("--pause and --no-pause are mutually exclusive")
}

Try / catch

if err := cmd.Execute(); err != nil {
    if strings.Contains(err.Error(), "--no-pause and --pause cannot be used together") {
        // remove one flag and retry / inform user
    }
}

Prevention

When it happens

Trigger: Running `docker commit --pause --no-pause <id>` or `docker commit -p --no-pause <id>`. Both flags have their Changed flag set because the user (or a wrapper) passed both.

Common situations: Aliases/scripts that append --no-pause colliding with a user's --pause; copy-pasting flags from old docs (when --pause was the norm) alongside new --no-pause; refactors that didn't remove the deprecated flag.

Related errors


AI-assisted analysis of docker/cli@4f84911bfe (2026-08-07). Data as JSON: /api/errors/0bdfce490de63841. Report an issue: GitHub.

Appendix: source

Thrown at cli/command/container/commit.go:42

	changes opts.ListOpts
}

// newCommitCommand creates a new cobra.Command for `docker commit`
func newCommitCommand(dockerCLI command.Cli) *cobra.Command {
	var options commitOptions

	cmd := &cobra.Command{
		Use:   "commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]",
		Short: "Create a new image from a container's changes",
		Args:  cli.RequiresRangeArgs(1, 2),
		RunE: func(cmd *cobra.Command, args []string) error {
			options.container = args[0]
			if len(args) > 1 {
				options.reference = args[1]
			}
			if cmd.Flag("pause").Changed {
				if cmd.Flag("no-pause").Changed {
					return errors.New("conflicting options: --no-pause and --pause cannot be used together")
				}
				options.noPause = !options.pause
			}
			return runCommit(cmd.Context(), dockerCLI, &options)
		},
		Annotations: map[string]string{
			"aliases": "docker container commit, docker commit",
		},
		ValidArgsFunction:     completion.ContainerNames(dockerCLI, false),
		DisableFlagsInUseLine: true,
	}

	flags := cmd.Flags()
	flags.SetInterspersed(false)

	// TODO(thaJeztah): Deprecated: the --pause flag was deprecated in v29 and can be removed in v30.
	flags.BoolVarP(&options.pause, "pause", "p", true, "Pause container during commit (deprecated: use --no-pause instead)")
	_ = flags.MarkDeprecated("pause", "and enabled by default. Use --no-pause to disable pausing during commit.")

View on GitHub (pinned to 4f84911bfe)